Skip to content
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

First pass at autodoc support #464

Merged
merged 14 commits into from Oct 30, 2019
Merged

First pass at autodoc support #464

merged 14 commits into from Oct 30, 2019

Conversation

tomchristie
Copy link
Member

@tomchristie tomchristie commented Oct 9, 2019

I've started working on an autodoc extension for use with mkdocs.

This pull request demonstrates using it with the httpx.request function, just for visibility of where I think we need to go here.

Bits to do:

  • Nested code blocks in the docstring are not rendering. (I tried installing the pymdownx.superfences extension, which didn't appear to resolve the issue, either. *Any help with resolving this would be much appreciated.**) - Resolved
  • Need to look at rendering classes, not just functions. More complicated. There's some limited support for this, but will need work. - Resolved
  • Rendering docs for instance attributes on classes. This is more awkward to do than methods & properties, since we can only figure out instance attributes by grepping the code in the __init__.
  • Ensure async methods get an "async" marker. We're not rendering any of these yet in this PR, so not currently an issue.
  • I'm using a dd element as a bit of a styling hack, as it gives me a nicely indented block for the docstring. Probably ought to be a div with an appropriate class, or some other appropriate block element, with styling applied ideally by mkdocs-material, rather than having to add custom styling for it. - Resolved
  • It'd be really nice to keep the typing information out of the main display, but have contextual information pop up against parameters. We can treat this as a nice-to-have-later.

Screen Shot 2019-10-09 at 11 45 39

@tomchristie
Copy link
Member Author

Here's how we're looking now...

aIAgAAjQpG

I think we're possibly(?) far along with this now that we could consider pulling it in, and then making incremental improvements as we go. It's a bit tricky trying to judge how much typing information to include in docstring descriptions when a parameter can accept a number of different types - I've not been terribly precise about that yet - would be happy to either try to clean anything up comprehensively in this PR, or take this as a starting point.

Things that would be nice in the future:

  • Ensure that mkautodocs adds an <em>async</em> in front of any async methods/functions.
  • Add contextual typing information to parameters. (Keep it hidden by default, but all hover or click popovers)
  • Support documenting instance attributes. (Infer self.<some_valid_variable_name_pattern = from docstrings, and use any leading comment blocks prior to that as the docs.)

@florimondmanca
Copy link
Member

@tomchristie Do you think this is ready for review, and potentially merging in?

@tomchristie
Copy link
Member Author

@florimondmanca Yes I think so. Obvs we'll have some work to do on:

  • Fleshing things out more.
  • Figuring out a good approach to how much type information to talk about in the docstrings
  • Figuring out a good approach to doc string styling.
  • Improving functionality, eg. include contextual type information on hover/click or similar.

But from my POV I think it's probably worth us getting in, and then iterating on.

Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

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

Yup, looks good to me! Just a few possible typos.

httpx/api.py Outdated Show resolved Hide resolved
httpx/client.py Outdated Show resolved Hide resolved
@florimondmanca
Copy link
Member

I fixed the few typos from my last review, merging in now! 🎉

@florimondmanca florimondmanca merged commit 1ce3cc3 into master Oct 30, 2019
@florimondmanca florimondmanca deleted the autodoc branch October 30, 2019 15:21
@tomchristie
Copy link
Member Author

Thanks! 😃

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.

None yet

2 participants