Skip to main content

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/.

Metadata

Release files for pear-cli 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pear-cli 0.2.1
File Size Uploaded Provenance Actions
pear-cli-0.2.1.tar.gz 7.0 kB Without provenance Details for pear-cli-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pear-cli 0.2.1
File Interpreter ABI Platform Actions
pear_cli-0.2.1-py3-none-any.whl Python 3 none any Details for pear_cli-0.2.1-py3-none-any.whl

Total release size: 13.9 kB

Release files / pear-cli-0.2.1.tar.gz

Download URL pear-cli-0.2.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
878c680ac5c9ffed6d66280f7c38bd09f9d0d64b932994be3f7fc5172b2415ed
BLAKE2b-256 checksum
How to use checksums
332197337410a81610ffc2fe16917d8aad286a5d1f3e781fe0cf5c07dce1a2aa
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pear_cli-0.2.1-py3-none-any.whl

Download URL pear_cli-0.2.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db7cabb2e1fbb918159a8c4e23c2b42cdfb718f3fcc9dacbe5db2afcb850de52
BLAKE2b-256 checksum
How to use checksums
d527e7193b39939c5526e0fa03f103e02669dd7082808706b368e767c409d0ea
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for pear-cli 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page