Convenience functions to extract docstring and write README
Project description
Convenience functions to extract docstring and write README
Intent: store one copy of top-level docstring in <package>/__init__.py
Allows generation of top level gitub README based on the package docstring
Features
Determine package name from current directory
Extract docstring using Python semantics and standards
No dependencies outside standard library
Uses abstract syntax tree parsing for relative __init__.py files
Examples
Print the first line of a docstring:
>>> import gleandoc
>>> docstring = gleandoc.docstring('re')
>>> docstring.splitlines()[0]
'Support for regular expressions (RE).'
>>>
Do the same thing from the command line:
$ gleandoc re | head -1
Support for regular expressions (RE).
$
Interpolate template README.rst.fstr and write results to README.rst, replacing {__doc__} with extracted docstring based on the name of the current directory:
$ gleandoc README.rst.fstr README.rst
gleandoc: WARNING: replacing README.rst
gleandoc: INFO: wrote README.rst
$
The -h option at the command line will show supported options:
$ gleandoc -h
Usage: gleandoc [-h] [NAME]
Extract docstring from module [NAME]
-h, --help show this help message and exit
- If unspecified, NAME defaults to the basename of the current directory
- This is designed for use in build systems to construct README files
Alternative two argument usage: gleandoc TEMPLATE README
Interpolate docstring into TEMPLATE and write results to README
- In this mode, always derives NAME from basename of current directory
- Template uses style similar to f-string
- Supported variables which will be interpolated include: {__doc__}
- For literal (single) braces, use double braces: {{ or }}
Limitations
Embedded backslash-n newlines are treated as actual newlines
Relies on various pseudo-internals: locals(), exec()
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
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
File details
Details for the file gleandoc-0.3.0.tar.gz
.
File metadata
- Download URL: gleandoc-0.3.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23ed1a4444ea2f46c55d6d9dd9d7f3eb9fd34b27c02d59113abc858d65c00b85 |
|
MD5 | 2d1c1dbf843806ba5f5bd35b16675bb0 |
|
BLAKE2b-256 | ada442ceac07adcd6f12b561f0391fc9bcbae8d76c3b7eebdfc052745b064e3d |
File details
Details for the file gleandoc-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: gleandoc-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e992838a1113b00c144937c078f8085a65b4d62a9fcd6ea4a2ce5d535e36465e |
|
MD5 | d52167dcf339cdd7e8c0e4163696d902 |
|
BLAKE2b-256 | 8f77108f1f86f440fb1c3cd689fca3ebe067541852ed2e19a600dca1af6bd877 |