-
-
Notifications
You must be signed in to change notification settings - Fork 11
Add a monkey-patch to VariableCommentPicker to make auto_member_order work. #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… = 'bysource' work. Tested.
Thanks for taking this on! So first... apparently the tests are failing because the module we're trying to import from doesn't exist on sphinx 1.5. That's sphinx for you I guess. Gotta do something about that before we can merge this. I see two options:
The latter is a little more work, but if you feel comfortable doing it then it's probably what we want to do anyway (and might simplify testing). Speaking of release notes, you should also add one for this change :-). I guess the "auto_member_def order works now" release note would be Okay, and the final question is about testing this. Ugh. Testing sphinx is always kind of annoying, but... also kind of necessary, because sphinx changes things all the time, and this is particularly fragile because it's monkeypatching. So how can we test this. I guess the current I think the best bet here is to give up on being clever and write a hard-coded test. Like, we can set up a little sphinx source directory like def test_member_order_by_source(tmpdir):
shutil.copytree(str(Path(__file__).parent / "test-member-order-by-source"),
str(tmpdir / "test-member-order-by-source"))
subprocess.run(
["sphinx-build", "-v", "-nW", "-nb", "html",
str(tmpdir / "test-member-order-by-source"), str(tmpdir / "out")])
html = (tmpdir / "out" / "whatever-we-call-it.html").read_text("utf-8")
# Make some assertions about what order the different members show up in the html
# Maybe something like:
# Listed in the order they should appear
members = ["foo", "bar", "another_method", "this_one_is_async", "this_one_is_sync"]
first_mention_offsets = [html.find(member) for member in members]
assert all(offset >= 0 for offset in first_mention_offsets)
# check they show up in the same order as our list
assert sorted(first_mention_offsets) == first_mention_offsets Does that make sense? Sorry it's kind of long -- I don't think any piece is too much, despite how many words it takes to describe, but if you have trouble with anything or don't have the time then just let me know and we'll figure something out. |
Well, I've noticed the failed tests. I think the second option is better. I will take more time to think about it as I'm not familiar with your project's structure. Maybe in two days. About the test, at first I was thinking about adding a new |
Whoops, just noticed that I had a bad copy-paste error in the middle of my comment. I've just edited it to fix it. So if you were finding it super hard to read, that was my fault :-) |
Codecov Report
@@ Coverage Diff @@
## master #14 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 3 3
Lines 253 264 +11
Branches 40 42 +2
=====================================
+ Hits 253 264 +11
Continue to review full report at Codecov.
|
Well, almost there except for failed assertion... |
Fix another typo.
As you can see, almost done. How does cov calculate? Does it mean I need to add a test case for that "if not hasattr"? |
Nicely done! Yeah, the coverage is complaining about that Also, we still need a newsfragment. Other than those two things, I think this looks good! That test is quite clever :-) |
Fine, leart about coverage tool. And then, so let's say now I should add two newsfragments which are "13.bugfix.rst" and "14.removal.rst". But I cannot see Could you explain a little bit more about this? |
Ops, I understand. That number is PR's number and issue's number. Give me one second. |
BTW, fix a bug in pyproject.toml
Fix coverage problem
Well well, I believe everything is OK. |
Oh, I'm a dork. I was all like "wait, why is @Sraw using I'm sorry, I should have said (and thought I said) (The difference is that |
Eh, I'm just going to fix that myself and merge it, because it's such a silly little fix (and I feel silly for telling you the wrong thing) |
It doesn't matter :) I've really learnt a lot. |
You're welcome, and thank you! And, no pressure, but if you'd like to keep contributing then we'd love to have you, so I'm sending you a github invite now. You can read more about this in our contributing documentation. |
Just a quick word to thank all people involved in fixing this issue. |
I have tested this PR on your
autodoc_examples.py
.But I didn't add some tests about it. Not sure is it needed or not.