forked from NanoComp/meep
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Python docstrings (NanoComp#1240)
* 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 <>
- Loading branch information
Showing
21 changed files
with
11,921 additions
and
1,520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
This is the documentation tree for MEEP. | ||
|
||
markdown (.md) files are in the `doc/docs` folder. | ||
|
||
To build and visualize the HTML documentation locally using the | ||
mkdocs package (useful for verifying changes on your local machine | ||
before committing), first install `mkdocs` (version 0.17.5) as | ||
well as two auxiliary packages via e.g.: | ||
|
||
``` | ||
% pip3 install --user mkdocs==0.17.5 python-markdown-math mkdocs-material | ||
``` | ||
|
||
To (re)generate the Python API documentation (extracted from the docstrings) | ||
run the following command in the project root folder. Note that this requires | ||
that the Python extension for the meep library has been built: | ||
|
||
``` | ||
% PYTHONPATH=./python python doc/generate_py_api.py | ||
``` | ||
|
||
Rerun this after making any changes to the docstrings in the source and | ||
rebuilding the project, in order to update the documentation. | ||
|
||
Next, run the following command from the top-level MEEP repository tree: | ||
|
||
``` | ||
% mkdocs serve | ||
``` | ||
|
||
Finally, open the following address in a browser window: | ||
|
||
http://127.0.0.1:8000 | ||
|
||
This launches a web server on your local machine plus a filesystem hook for | ||
rebuilding the documentation tree automatically whenever any .md file is | ||
modified. This enables viewing the HTML documentation in real time as the | ||
source files are edited. | ||
|
||
To build the HTML version of the documentation, run: | ||
|
||
``` | ||
% mkdocs build | ||
``` | ||
|
||
The results will be put into the `./doc/site` folder. | ||
|
||
Alternatively, the project `Makefile` can also be used to build the | ||
documentation and to build a distribution archive containing the | ||
documentation. To do so, run one of the following commands from the | ||
top-level MEEP repository tree: | ||
|
||
``` | ||
# Only regenerate the Python API document, useful if you're using `mkdocs serve` | ||
% make python_api_doc | ||
# Regenerate the API doc and run `mkdocs build` | ||
% make docs | ||
# Bundle the HTML version of the document files into a tarball archive | ||
% make docs-dist | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
<a id="{class_name}"></a> | ||
|
||
### {class_name} | ||
|
||
```python | ||
class {class_name}({base_classes}): | ||
``` | ||
|
||
<div class="class_docstring" markdown="1"> | ||
|
||
{docstring} | ||
|
||
</div> | ||
|
||
<div class="class_members" markdown="1"> | ||
|
||
{method_docs} | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
<a id="{function_name}"></a> | ||
|
||
**meep.{function_name_escaped} function** | ||
|
||
```python | ||
def {function_name}{parameters}: | ||
``` | ||
|
||
<div class="function_docstring" markdown="1"> | ||
|
||
{docstring} | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
<a id="{class_name}.{method_name}"></a> | ||
|
||
**{class_name}.{method_name_escaped}** | ||
|
||
```python | ||
def {method_name}{parameters}: | ||
``` | ||
|
||
<div class="method_docstring" markdown="1"> | ||
|
||
{docstring} | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.