11# MyDocstring
2- [ MyDocstring] ( README.md ) is a small Python package that allows you to extract docstrings display them as either plain-text, [ Markdown] ( http://commonmark.org/ ) , or [ JSON] ( https://www.json.org/ ) data.
2+ [ MyDocstring] ( README.md ) is a small Python package that allows you to extract and parse docstrings. It suited for building your own documentation system. Docstrings can be displayed as either plain-text, [ Markdown] ( http://commonmark.org/ ) , or [ JSON] ( https://www.json.org/ ) data.
33
4- * Support for Python-code (support for C-code is planned).
5- * Support for [ Google-style docstrings] ( http://google.github.io/styleguide/pyguide.html )
4+ * Supports [ Python PEP484 type hints] ( https://www.python.org/dev/peps/pep-0484/ ) .
5+ * Supports [ pybind11] ( https://github.com/pybind/pybind11 ) docstrings.
6+ * Supports [ Google-style docstrings] ( http://google.github.io/styleguide/pyguide.html ) .
67* Produces [ JSON] ( https://www.json.org/ ) , plain-text, and [ Markdown] ( http://commonmark.org/ ) output for modules, classes, functions, and
78 methods.
89
910## Getting Started
10- You can begin extracting and converting docstrings using the command line tool
11- ` mydocstring ` that comes with package. Simply type ` mydocstring --help ` to see how to use it.
11+ If you are interested in building a documentation solution for your own
12+ project, a good place to
13+ start is this [ tutorial] ( tutorials/begin.ipynb ) . This tutorial will teach you
14+ how to extract and parse docstrings.
1215
13- Let's extract the docstring from the following example code and convert it to
14- Markdown:
15- ``` python
16- def example_function (arg1 , arg2 = 1 ):
17- """
18- This is an example of a docstring that conforms to the Google style guide.
19- The indentation uses four spaces (no tabs). Note that each section starts
20- with a header such as `Arguments` or `Returns` and its contents is indented.
21-
22- Arguments:
23-
24- arg1 (`int`): This description for this argument fits on one line.
25- arg2 (`int`, optional): This description is too long to fit on a
26- single line. Note that it is continued by being indented.
27-
28- Returns:
29-
30- `bool` : Stating the return type here is optional.
31-
32- We can continue putting explanations in this section as long as the text
33- is indented.
34-
35- This text is no longer indented and therefore not part of the `Returns`
36- section.
37-
38- Raises:
39-
40- ValueError: This is exception is raised when arg1 and arg2 are equal.
41-
42- """
43- if arg1 == arg2:
44- raise ValueError (" `arg1` and `arg2` cannot be equal." )
45- if arg1 > arg2:
46- return True
47- else :
48- return False
49- ```
50- This example code can be found here: [ examples/example.py] ( examples/example.py ) .
51-
52- To convert to Markdown, we simply use
53- ```
54- $ docstring examples/example.py example_function --markdown > examples/example_py.md
55- ```
56- The following rendered Markdown is produced:
57-
58- ---
59- # example_function
60- ``` python
61- def example_function (arg1 , arg2 = 1 ):
62- ```
63-
64- ---
65-
66-
67- This is an example of a docstring that conforms to the Google style guide.
68- The indentation uses four spaces (no tabs). Note that each section starts
69- with a header such as ` Arguments ` or ` Returns ` and its contents is indented.
70-
71- ## Arguments
72- * ** arg1** (` int ` ) : This description for this argument fits on one line.
73- * ** arg2** (` int ` , optional) : This description is too long to fit on a
74- single line. Note that it is continued by being indented.
75-
76-
77- ## Returns
78- * Stating the return type here is optional.
79-
80-
81- We can continue putting explanations in this section as long as the text
82- is indented.
83-
84- ---
85- This text is no longer indented and therefore not part of the ` Returns `
86- section.
87-
88- ## Raises
89- * ** ValueError** : This is exception is raised when arg1 and arg2 are equal.
90-
91-
92-
93-
94- ## Source
95- ``` python
96- def example_function (arg1 , arg2 = 1 ):
97- if arg1 == arg2:
98- raise ValueError (" `arg1` and `arg2` cannot be equal" )
99- if arg1 > arg2:
100- return True
101- else :
102- return False
103-
104- ```
105-
106- ---
107- The output above can also be found here: [ examples/example_py.md] ( examples/example_py.md ) .
108-
109- If you are not satisfied with the resulting Markdown, you can provide your own
110- [ mako] ( http://makotemplates.org ) template
111-
112- ```
113- $ docstring examples/example.py example_function --markdown --template customization.md
114- ```
115- Go to [ mydocstring/templates/] ( mydocstring/templates/ ) to see how to make your own
116- template.
117-
118- It is also possible to output plain-text, or JSON-data using the flags args
119- ` --text ` and ` --json ` . Example output can be found here: [ examples/] ( examples/ ) .
16+ If you are after a complete documentation solution, then see the
17+ [ showcase] ( #showcase ) section that features solutions built on * MyDocstring* .
12018
19+ The project also comes with a command line tool that serves as an example of
20+ what you can build with the package. See [ here] ( examples/README.md ) for learning
21+ how to use the command line tool and to see some example output.
12122
12223## Installation
12324The package is available on the Python packaging index [ PyPi] ( https://pypi.python.org/pypi ) and can be installed via pip as follows.
@@ -127,7 +28,7 @@ $ pip install mydocstring
12728
12829## Dependencies
12930This project uses:
130- * [ docopt] ( http://docopt.org/ ) for the command- line interface application.
31+ * [ docopt] ( http://docopt.org/ ) for the command line interface application.
13132* [ mako] ( http://www.makotemplates.org/ ) for producing markdown templates.
13233* [ pytest] ( https://docs.pytest.org/en/latest/ ) for testing.
13334
@@ -143,28 +44,19 @@ Otherwise, please submit a new issue using the [issue tracker](https://github.co
14344
14445## Contributing
14546Contributions are more than welcome. Please reach out via the issue tracker to
146- discuss and also see [ here] ( contributing .md) for
47+ discuss and also see [ here] ( CONTRIBUTING .md) for
14748some guidelines.
14849
14950## Showcase
15051If you end up using this tool in your project in one way or another. I would
15152love to hear about it and showcase it here. Please go ahead and make a pull
15253request.
15354
154- ## Acknowledgments
155- These are some projects that inspired me to develop this tool.
156- * [ pdoc] ( https://github.com/BurntSushi/pdoc/ ) A tool for auto-generating API
157- documentation for Python libraries.
158- * [ mkdocs] ( http://www.mkdocs.org/ ) Static site generator for building
159- documentation using markdown.
160- * [ moxygen] ( https://github.com/sourcey/moxygen ) Doxygen XML to Markdown
161- converter.
162- * [ napoleon] ( https://pypi.python.org/pypi/sphinxcontrib-napoleon ) Sphinx
163- extension that can parse numpy and Google-style docstrings.
164- * [ pypydoxify] ( https://pypi.python.org/pypi/doxypypy/0.8.8.6 ) Converts Python
165- comments into Doxygen's syntax.
166- * [ docsify] ( https://github.com/QingWei-Li/docsify/ ) Markdown-based documentation
167- site generator.
55+ * [ NetKet] ( https://www.netket.org ) is a open-source project for machine learning and
56+ many-body quantum systems. It uses * mydocstring* for generating reference
57+ documentation from [ pybind11] ( https://github.com/pybind/pybind11 ) docstrings.
58+ See
59+ [ here] ( https://github.com/netket/netket/tree/v2.0/Docs ) for the source.
16860
16961## License
17062
0 commit comments