Embed your documentation inside runnable examples
Project description
Exemplary
A tool which provides extremely simple way to generate markdown documentation from actual source code examples!
Requirements
The requirements for using this package are:
- Python (>= 3.8).
Installation Guide
Install the package as you would any other, using pip
:
> pip install python-exemplary
# or use `pipx` for virtual-env isolation
> pipx install python-exemplary
Check if it worked by running:
> exemplary --help
Usage Guide
Using exemplary
is really easy. Upon installing the package, now a program called exemplary
should be
available to run.
exemplary
works by reading your source-code; finding what must be comments; and wrapping the documents by
the specified processors.
But why use words when examples do the trick?
Take for example the following Python script:
# myscript.py
def main():
# @start md
# # Exemplary Example!
#
# First when you want to add 1 to a number, you gotta start with a number.
# Let's create a number-containing variable called "num"
# @end
# @start py
num = 1
# @end
# @start md
# And now let's just "+ 1" it, saving the result to "result".
# @end
# @start fence {"lang": "python"}
result = num + 1
# @end
# @start md
# Fantastic! Now let's print the result to see how we did
# @end
# @start py
print(result)
# @end
if __name__ == "__main__":
main()
Let's break it down:
@start
- Those signify the start of a block to be processed. Themd
/py
signify which processor will handle the text-segment. There are currently 3 processors:md
/markdown
- Strips the comment pattern (in this case#
) and simply insert the block content as is.fence
- A classic markdown fence. The language is determined in the following arguments.py
/python
- A shortcut for Python fence-blocks.
@end
signify the end of a block.- ..And everything else in the middle, is the aforementioned blocks.
By running the command:
> exemplary generate myscript.py
The output of the generated Markdown will be printed on screen:
# Exemplary Example!
First when you want to add 1 to a number, you gotta start with a number.
Let's create a number-containing variable called "num"
``` python
num = 1
```
And now let's just "+ 1" it, saving the result to "result".
``` python
result = num + 1
```
Fantastic! Now let's print the result to see how we did
``` python
print(result)
```
...And that's it. Nothing else to it. Have fun documenting!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python_exemplary-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b03923fca25ee788d307fdff6589cbdc15ffc29ee8665bcb8c2341a6e93e445 |
|
MD5 | 68a359e3c628768a4175b3b78611654f |
|
BLAKE2b-256 | a3a37a3e1d7a8255d84c9cdb10e34ca4eef0ebe416557d8e81a3dc9fc229c844 |