Skip to main content

sphinxcontrib-eval

pre-commit.ci status github/workflow codecov readthedocs

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

pypi/status pypi/v pypi/downloads pypi/format pypi/implementation pypi/pyversions

Evaluate shell command or python code in sphinx and myst.

Usage

Enable

docs/conf.py

extensions = [
    "sphinxcontrib.eval",
]

Or

extensions = [
    "myst_parser",
    "sphinxcontrib.eval",  # must be after myst_parser
]

Demonstration

For myst:

```{eval-sh}
echo My OS is $OSTYPE.
```

For rst:

.. eval-sh::
    echo My OS is $OSTYPE.

Then build:

sphinx-build docs docs/_build/html

Result:

My OS is linux-gnu.

NOTE: the current working directory depends on you. That is, if you run cd docs && sphinx-build . _build/html && cd -, CWD will be docs, which is the default setting of https://readthedocs.org. So if your code structure is like

$ tree --level 1
 .
├──  docs
├──  scripts
├──  src
└──  tests

And you want to run scripts/*.sh, you need cd .. firstly from docs to . else you have to run ../scripts/*.sh.

Advanced Usages

All of the following examples are myst. The corresponding examples of rst are similar. Click the hyperlinks of the titles and scripts to see the actual examples.

Generate API Document

Before:

# API of Translate Shell

```{eval-rst}
.. automodule:: translate_shell
    :members:
.. automodule:: translate_shell.__main__
    :members:
... (More)
```

Now

# API of Translate Shell

````{eval-rst}
```{eval-sh}
cd ..
scripts/generate-api.md.pl src/*/*.py
```
````

Where scripts/generate-api.md.pl is a script which replace all src/translate_shell/XXX.py to

.. automodule:: translate_shell.XXX
    :members:

Generate TODO Document

Before:

# TODO

- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/translators/stardict/__init__.py#L4>
  more stardicts.
- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/translators/stardict/__init__.py#L5>
  Create different subclasses for different dict to get phonetic, explains
- <https://github.com/Freed-Wu/tranlate-shell/tree/main/src/translate_shell/ui/repl.py#L33>
  make the last line gray like ptpython
- ...

Now: (notice eval-bash because readthedocs uses dash as their default $SHELL)

# TODO

```{eval-bash}
cd ..
scripts/generate-todo.md.pl src/**/*
```

Where scripts/generate-todo.md.pl searches all TODOs in code then convert them to correct hyperlinks.

Generate Requirements Document

Before:

# Requirements

## completion

Generate shell completion scripts.

- [shtab](https://pypi.org/project/shtab)

...

Now

# Requirements

```{eval-sh}
cd ..
generate-requirements.md.pl
```

Where scripts/generate-requirements.md.pl searches all requirements/*.txts and requirements/completion.txt is:

#!/usr/bin/env -S pip install -r
# Generate shell completion scripts.

shtab

See document to know more.

Metadata

Release files for sphinxcontrib-eval 0.0.3

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

Source distribution (sdist)

Source distribution for sphinxcontrib-eval 0.0.3
File Size Uploaded Provenance Actions
sphinxcontrib-eval-0.0.3.tar.gz 29.2 kB Without provenance Details for sphinxcontrib-eval-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sphinxcontrib-eval 0.0.3
File Interpreter ABI Platform Actions
sphinxcontrib_eval-0.0.3-py3-none-any.whl Python 3 none any Details for sphinxcontrib_eval-0.0.3-py3-none-any.whl

Total release size: 47.8 kB

Release files / sphinxcontrib-eval-0.0.3.tar.gz

Download URL sphinxcontrib-eval-0.0.3.tar.gz
Size 29.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e184b0216ee5d07711dbdde5d79a71313e92010d363e318f63125dce37a19129
BLAKE2b-256 checksum
How to use checksums
741ad4a57147771faa8e1466ca56de0d95621575af3ac4768c9e14c3198ed554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Release files / sphinxcontrib_eval-0.0.3-py3-none-any.whl

Download URL sphinxcontrib_eval-0.0.3-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9fb71dc1901039378b0ee5a12ac74c2140a458cd2ac7a5b18ad8a344caf5505
BLAKE2b-256 checksum
How to use checksums
ea8d1d9fda5bd281aaf17163eb64f6bac4eff924b5ac54b398d35ae0d4796ede
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Security for sphinxcontrib-eval 0.0.3

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