-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Provider method autodoc and sample autogeneration #1128
Conversation
@fcurella i made some more changes, specifically the ability to set the number of samples per batch and the initial seed for that batch. Oversimplified example, if provider method
Something like this will be autogenerated under the
I made this change, because over the course of rewriting some of the docs, I realized the generated examples will still be lacking under the old design. For example, you cannot properly demonstrate how random sampling methods actually work if you can only generate one sample at a time. Anyway, I updated the |
@malefice my only issue is that |
@fcurella I am not so sure if What do you think?
Or maybe these?
|
I like |
@fcurella Already made the change. Furthermore, I have also investigated the pypy3.5-6.0 build failure. Something in that pypy version triggers a segmentation fault if By the way, sphinx logging is used to show warnings on invalid samples and failed sample generation. How do you want to proceed with this? |
Thank you so much for all your work @malefice ! I would just switch to the standard |
Personally, I would just opt to use Sphinx logging, because I prefer to keep the logging part uniform with how Sphinx handles it. There are also some minor differences, but as to how important the differences are for our use case, it will be your call. Sphinx logging already uses its own logging configuration as shown here, and it collects all logging output and neatly shows them after all source files have been read. Warning messages will also be in red. Out of the box, standard library |
Thank you @malefice , let's go with the standard |
@fcurella Despite the coronavirus outbreak, I have reason to believe that I will become increasingly busy over the next few weeks. I am thinking of wrapping this one up by just finishing the docstrings for modules I already started and writing some docs on how to write samples. Hopefully it will be possible for you to merge this PR in that state. At least that way, other people can also start writing docs as well VS waiting for me to finish this huge task. I am also thinking that we should also exclude the Anyway, your thoughts? |
@malefice I wuld be ok with excluding I'm ok with merging the PR even if we don't have all docstrings. Thank you so much for all your hard work. Your help has really been invaluable. Take care and take it easy during these hard times :) |
@fcurella Thank you, and please do take care of yourself as well! Anyway, I placed all the sphinx docs stuff inside |
Merging this in. Thank you so much! |
* Add sample code validator class * Create build_docs replacement * Enforce sorting on AVAILABLE_LOCALES * Create provider method docstring preprocessor * Configure sphinx to use new autodoc setup * Reverse part of cdd79d5 * Prettify barcode provider docstring * Assortment of changes to ProviderMethodDocstring * Add more tests * Allow use of OrderedDict in samples * Fix flake8 errors * Fix isort errors * Add sphinx to tox.ini testenv deps * Exclude autodoc files from coverage * Fix one last isort error * Allow multiple results and seeding * Remove old build_docs * Update base provider docs * Fix flake8 and isort errors again * Force usage of size kwarg in sample generation * Revert typo introduced in 4d00704 * Improve logging * Improve results stringification * Finalize barcode provider docs * Finalize standard provider docs * Finalize misc provider docs * Improve color provider docs * Autogenerate default sample for insufficient docstrings * Exclude faker.sphinx and tests.sphinx from release distributions * Add docs on writing docs * Fix check-manifest errors * Fix faker.sphinx not found error in RTD * fix small grammar issues Co-authored-by: Flavio Curella <89607+fcurella@users.noreply.github.com>
What does this change
If accepted, the old
build_docs
will be replaced with a new autodoc system that will allow provider method docs to be more comprehensive.What was wrong
Current docs are lacking as discussed in #1083.
How this fixes it
The project will now use Sphinx's AutoDoc extension to generate docs for provider methods from docstrings. Furthermore, it is possible to specify sample invocations inside the docstrings using a very simple syntax. Those will be parsed during docstring preprocessing, and the results of each valid invocation will be presented as well. A sample docs site using this system can be viewed here
Further thoughts
One side effect of the old
build_docs
system was the implicit inability to create provider methods with required arguments without default values. Attempting to do so will cause the docs building process to fail.For example, the
bothify
method accepts atext
argument with the default value of'## ??'
. Semantically, it does not really make sense for that method to have a default value fortext
anyway, since users will most likely supply their own values fortext
. Should this new system be accepted, it will be possible to create such provider methods without causing the autodoc system to fail while still being able to showcase what each provider method is capable of.Fixes #1083