A utility for generating variations of source code for docmentation
Project description
pear
A utility for generating variations source code for docmentation.
In documentation you might want to show the growth of a file over time. However, if you want to keep only one copy of the source code. Consider the following file:
class Foo:
def __init__(self, name):
self.name = name
def reverse_name(self):
return self.name.reverse()
If we can to incrementally build the file, we might write the constructor first and reverse_name second. That means we would want two versions of the file:
class Foo:
def __init__(self, name):
self.name = name
class Foo:
# constructor
def reverse_name(self):
return self.name.reverse()
Using pear you can accomplush this.
Usage
Include a pear.json file in your root directory with the necessary configurations. For our above example, we would have:
{
"out": "out",
"files": [
{
"path": "foo.py",
"tag": "without_reverse_name",
"layers": [
{
"type": "remove",
"start": 4,
"end": 6
}
]
},
{
"path": "foo.py",
"tag": "constructor_comment",
"layers": [
{
"type": "replace",
"start": 2,
"end": 3,
"replacement": [
" # constructor"
]
}
]
}
]
}
Then call pear from the same directory. This will generate foo.py_without_reverse_name and foo.py_constructor_comment files in out/.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pear-cli-0.2.1.tar.gz.
File metadata
- Download URL: pear-cli-0.2.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
878c680ac5c9ffed6d66280f7c38bd09f9d0d64b932994be3f7fc5172b2415ed
|
|
| MD5 |
09cd991943b8a784318649409820392e
|
|
| BLAKE2b-256 |
332197337410a81610ffc2fe16917d8aad286a5d1f3e781fe0cf5c07dce1a2aa
|
File details
Details for the file pear_cli-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pear_cli-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db7cabb2e1fbb918159a8c4e23c2b42cdfb718f3fcc9dacbe5db2afcb850de52
|
|
| MD5 |
cea62eb899167a74f43a2f28a38b7c77
|
|
| BLAKE2b-256 |
d527e7193b39939c5526e0fa03f103e02669dd7082808706b368e767c409d0ea
|