-
Notifications
You must be signed in to change notification settings - Fork 637
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
Add Python docstrings #1240
Add Python docstrings #1240
Conversation
I like where this is heading! One possibility would be to emulate the Documenter.jl package for Julia, which inserts Julia docstrings into Markdown documentation. Essentially, we would take our current Python API markdown document, and replace the documentation for e.g.
and then the postprocessing tool would insert the docstring for The advantages of this, rather than generating the Python API docs wholesale, are:
|
Yes, that's a good idea. I was thinking about adding some boolean class-level attribute to indicate if something should be added to the documentation, (defaulting to |
…, rather than as a collection of all classes found by the scan
This prevents a lot of noise in the documentation.
…r GDSII functions.
Is the generated |
I wasn't sure what the preference/policy on that would be. Since it's now generated some projects would just remove it from git. Others would keep it in and developers would need to ensure it is rebuilt and checked in when any changes are made that affect it. What makes the most sense to you? |
It would be nicer to not check it in, and build it automatically on commits. Unfortunately, since it requires Meep to be compiled, it may be too complicated for the mkdocs script. One option would be to build it as part of Travis, and store it with Travis build artifacts for later use during documentation generation. That probably requires some digging through the Travis docs to understand the artifacts system. |
…ed in the dist archive
…Python 2.7 builds
enable it to be run from anywhere and still find the templates, etc.
* First pass on tool to extract docstrings and add them to the main documentation. * Add templates used for building the Python API docs * Update docs README with new info * Add link to new API docs. The old is still there for now. * First pass on adding docstrings to the python code. * Clarify the note in the README about when to rebuild * Fix typo * Refactor doc generator tool to pull items into the master doc by name, rather than as a collection of all classes found by the scan * Fix typo * Use spaces inside the tag markers. It's more readable. * Reorder methods to ensure that __init__ comes first * Look only at items that are in the class, not all inherited members. This prevents a lot of noise in the documentation. * Move remaining class and method docs to docstrings * Fix typo in Simulation tag * Regenerate document * Copy recent changes from the non-template version of the document * Only load the template files once, and other light refactoring * Add doc generation support for functions * Continue moving documentation to doctrings * Add and export a GDSII_prisms function, for consistency with the other GDSII functions. * Fix some copy/paste mistakes * Expose the DtfFOO classes so their docstrings can be linked to * Move and link dostrings for GDSII, Run and Step, and Output sections * Move remaining documentation snippets to docstrings in the source. * Revert Python_User_Interface.md to avoid merge conflicts later. * Word-wrap and other formatting tweaks to help the docstrings be more readable in the code. * More docstring formatting * Typo fix * Add coding declaration to the top of the Python files. Python2 defaults to decoding source files to ASCII, so with non-ASCII characters in docstrings or other strings will result in a SyntaxError. * Add a .css file for custom configuration of styles without touching the existing theme files * Insert some <div class="..."> tags in the templates * Add styles * Ignore doc/site and an additional item in tests * Backslashes in docstrings need to be escaped * More template and style tweaks. * Remove the now generated Python_User_Interface.md file * Add support for building the documentation via the Makefile * rewrap paragraph * Set PYTHONPATH and use $(PYTHON) * Convert README to Markdown * `make dist` now depends on building the docs, and the docs are included in the dist archive * More info and clarification in the doc/README.md file * Include generate_py_api.py in the distribution * Fix building docs when configured in a separate build folder * Install the docs-related packages on Travis * Python 2.7 mkdocs has broken dependencies, skip building the docs on Python 2.7 builds * Python2 does not have f-strings * Use Python2-style super() * Also skip running the generator on Python2, for now. * Move generate_py_api script to the doc folder, enable it to be run from anywhere and still find the templates, etc. * Restore the generated API doc * cleanup * Revert including the docs build in the `make dist` and clean up the doc targets * Minor tweaks in doc/README.md Co-authored-by: Robin Dunn <>
Fixes #1236
First pass implementation of a tool to pull docstrings in markdown format from the Python code, and add them to the main documentation tree.
TODOs:
__init__
always comes first__repr__
methods for classes that are used as default parameter valuesFind way to auto-exclude SWIG and other lower-level or non-public things.Handle auto documenting other types of items, such as properties??Update intra-doc links to accomodate new document and anchor namesRemove the current Python Interface doc. (And rename the new one?)Not part of this PR, but IMO "{Language} User Interface" name is very misleading, "{Language} User API" would be better.