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

wip: Refactor as an extension #41

Merged
merged 29 commits into from
Mar 21, 2020
Merged

wip: Refactor as an extension #41

merged 29 commits into from
Mar 21, 2020

Conversation

pawamoy
Copy link
Member

@pawamoy pawamoy commented Jan 29, 2020

#28

@pawamoy pawamoy mentioned this pull request Jan 29, 2020
@pawamoy
Copy link
Member Author

pawamoy commented Feb 2, 2020

Just a few things to fix:

  • inline highlight
  • indented admonitions or markdown blocks (this one could need a rewrite of how we convert docstrings...)

Then clean up the code and we'll be good to go 🙂

A few things first. Since we run tools that collect
documentation in subprocesses, I was previously doing
this in two phases: first, in the on_nav event,
parse all pages to get the autodoc instructions
and group them by handler type, and then
collect all data at once by spawning the subprocess
just once. I was then injecting this data into the
mkdocstrings extension, so that it could use
it when rendering the markdown contents.

This was problematic because we needed to compute
hashes of the autodoc identifiers and selection
options, to make sure we were rendering the right
ones at the right time. Making sure everything
was computed and rendered correctly seemed
quite complex.

But the main reason I did this in two phases,
collecting instructions then running subprocesses,
was a performance reason. Indeed, spawning a new
subprocess (esp. Python)for each autodoc instruction
could make mkdocstrings very slow.

So I wondered: are there other ways to keep good
performance and proceed in a more linear manner,
collecting data and rendering it directly from
within the markdown extension?

Well, the answer is yes! Just have a process
that accepts input on stdin, line by line,
outputing the result on a single line as well,
and keep that process open until site
generation is done :) (then close it).

So that's what I'm doing now: when the markdown
extension hits an autodoc instruction, it gets
the associated handler (which is cached), collects
the data using the handler's collector, and
renders the data using the handler's renderer.

This is so much cleaner <3

Anyway, I just like writing a detailed commit
message sometimes.
@dtomlinson91
Copy link

Sorry if this isn't the right place, was the most sensible place I could find to ask.

I really really like what you have here, I think there's a potential for this to really take off. What do you need from contributions/community going forwards? I'd be interested in helping out.

@pawamoy
Copy link
Member Author

pawamoy commented Mar 14, 2020

Hey @dtomlinson91, totally the right place. I like it as well 😄
Thank you very much for offering your help, I really appreciate.

I'll open a new issue for people who'd like to contribute!

@pawamoy pawamoy mentioned this pull request Mar 14, 2020
@pawamoy
Copy link
Member Author

pawamoy commented Mar 18, 2020

🤤 We're almost there 🤤 🤤 🤤

  • Replicate current signatures: needs changes in pytkdocs to return serialized signature, and to write the signature.html template
  • Make sure we forward all recent changes in mkdocstrings documenter (through PRs) onto pytkdocs
  • Refine pytkdocs a bit and make a release
  • Refine mkdocstrings (docstrings, typing, todos, fixmes, cleanup) and make a release with the new architecture

@pawamoy
Copy link
Member Author

pawamoy commented Mar 21, 2020

We're done 🤤

@pawamoy pawamoy merged commit 4af2ba9 into master Mar 21, 2020
@pawamoy pawamoy deleted the refactor-extension branch April 6, 2021 18:21
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.

3 participants