Skip to content

Conversation

@johnzhou721
Copy link
Contributor

Fix #2851.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@johnzhou721
Copy link
Contributor Author

@freakboy3742 tox is passing (and said congrats to me :), hilarious) and I've written some hopefully not-too-bad tests, and updated the docstring and added a changenote for towncrier. Is there anything else I need in order to merge? Or, are there any more suggestions on how this is implemented? Thank you for reviewing!

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The broad shape of this is correct, with one note inline about the organization of the test cases.

However, the specific details of the implementation isn't consistent with the specification described in the ticket. The ticket says:

if content is specified, URL is the used as the root URL for the raw content.

That is - myview = WebView(url=myurl, content=mycontent) should be the equivalent of myview = WebView(); myview.set_content(myurl, mycontent), with the same caveat that is URL is provided, it will be ignored on some platforms (as documented in set_content()).

@johnzhou721 johnzhou721 requested a review from freakboy3742 May 2, 2025 02:42
an empty page will be displayed.
:param content: The static "non-URL" content to use for the WebView.
This supersedes the ``url`` parameter, since content and URL initialization
are mutually exclusive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment will need to be updated to reflect the new behavior.

root_url="https://example.com",
content="<h1>Hello, World!</h1>",
)
assert widget.url == "https://example.com"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My previous review said:

These two cases should be up around L55, after test_create_with_values - and should be named to match.

Also - the tests should pass before you request a review. This test has a fairly glaring error in it.

@johnzhou721
Copy link
Contributor Author

johnzhou721 commented May 2, 2025 via email

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a small tweak to the docstring, but otherwise, this looks good; thanks!

@freakboy3742 freakboy3742 merged commit 80e13e1 into beeware:main May 3, 2025
52 checks passed
@johnzhou721
Copy link
Contributor Author

Thanks. At the risk of embarrassing myself for asking, besides reading existing ones and see how they're written, how does one get better at writing docstrings?

@freakboy3742
Copy link
Member

Thanks. At the risk of embarrassing myself for asking, besides reading existing ones and see how they're written, how does one get better at writing docstrings?

Unfortunately, I'm not sure I have any better suggestions than "practice".

Writing is hard; writing with someone else's "voice" is even harder. The good news is that docstrings are easy for an editor to fix, because they're always self-contained to a single line/paragraph; and, as with most writing, the first draft is the hard part. If you're able to contribute a first draft that is in the vicinity of what is needed, I don't consider it a problem at all that a reviewer will tweak the specific text.

@johnzhou721
Copy link
Contributor Author

Writing is hard

Correct. I'm about to have my first A- semester average in my life if I don't work on my English Language Arts course at my school a bit. I mean this is easier since it's nonfiction and fiction's even harder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add content argument to WebView instantiation

2 participants