pretext

Command line interface for quickly creating, authoring, and building PreTeXt documents.

https://github.com/pretextbook/pretext-cli

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    4 of 10 committers (40.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.5%) to scientific vocabulary

Keywords from Contributors

transformation packaging embedded distributed charts autograd energy-system energy-system-model annotation meshes
Last synced: 10 months ago · JSON representation

Repository

Command line interface for quickly creating, authoring, and building PreTeXt documents.

Basic Info
  • Host: GitHub
  • Owner: PreTeXtBook
  • License: gpl-3.0
  • Language: Python
  • Default Branch: main
  • Homepage: https://pretextbook.org
  • Size: 4.09 MB
Statistics
  • Stars: 20
  • Watchers: 9
  • Forks: 26
  • Open Issues: 37
  • Releases: 111
Created about 6 years ago · Last pushed 10 months ago
Metadata Files
Readme Changelog License

README.md

PreTeXt-CLI

A package for authoring and building PreTeXt documents.

Documentation and examples for authors/publishers

Most documentation for PreTeXt authors and publishers is available at:

Authors and publishers may also find the examples catalog useful as well:

We have a few notes below (TODO: publish these in the Guide).

Installation

Installing Python

PreTeXt-CLI requires the Python version specified in pyproject.toml.

To check your version, type this into your terminal or command prompt:

python -V

If your version is 2.x, try this instead (and if so, replace all future references to python in these instructions with python3).

python3 -V

If you don't have a compatible Python available, try one of these:

  • https://www.python.org/downloads/
    • Windows warning: Be sure to select the option adding Python to your Path.
  • https://github.com/pyenv/pyenv#installation (Mac/Linux)
  • https://github.com/pyenv-win/pyenv-win#installation (Windows)

Installing PreTeXt-CLI

Once you've confirmed that you're using a valid version of Python, just run (replacing python with python3 if necessary):

python -m pip install --user pretext

(It's possible you will get an error like error: invalid command 'bdist_wheel' — good news, you can ignore it!)

After installation, try to run:

pretext --help

If that works, great! Otherwise, it likely means that Python packages aren't available on your “PATH”. In that case, replace all pretext commands with python -m pretext instead:

python -m pretext --help

Either way, you're now ready to use the CLI, the --help option will explain how to use all the different subcommands like pretext new and pretext build.

External dependencies

We install as much as we can with the pip install command, but depending on your machine you may require some extra software:

Upgrading PreTeXt-CLI

If you have an existing installation and you want to upgrade to a more recent version, you can run:

python -m pip install --upgrade pretext

Custom XSL

Custom XSL is not encouraged for most authors, but (for example) developers working bleeding-edge XSL from core PreTeXt may want to call XSL different from that which is shipped with a fixed version of the CLI. This may be accomplished by adding an <xsl/> element to your target with a relative (to project.ptx) or absolute path to the desired XSL. (Note: this XSL must only import other XSL files in the same directory or within subdirectories.)

For example:

<target name="html"> <format>html</format> <source>source/main.ptx</source> <publication>publication/publication.ptx</publication> <output-dir>output/html</output-dir> <xsl>../pretext/xsl/pretext-html.xsl</xsl> </target>

If your custom XSL file needs to import the XSL shipped with the CLI (e.g. pretext-common.xsl), then use a ./core/ prefix in your custom XSL's xsl:import@href as follows:

<xsl:import href="./core/pretext-common.xsl"/>

Similarly, entities.ent may be used:

<!DOCTYPE xsl:stylesheet [ <!ENTITY % entities SYSTEM "./core/entities.ent"> %entities; ]>

Note: previously this was achieved with a pretext-href attribute - this is now deprecated and will be removed in a future release.


Using this package as a library/API

We have started documenting how you can use this CLI programmatically in docs/api.md.


Development

Note. The remainder of this documentation is intended only for those interested in contributing to the development of this project. Anyone who simply wishes to use the PreTeXt-CLI can stop reading here.

From the "Clone or Download" button on GitHub, copy the REPO_URL into the below command to clone the project.

bash git clone [REPO_URL] cd pretext-cli

Using a valid Python installation

Developers and contributors must install a version of Python that matching the requirements in pyproject.toml.

Installing dependencies

Optional: use pyenv as a virtual environment The `pyenv` tool for Linux automates the process of running the correct version of Python when working on this project (even if you have other versions of Python installed on your system). - https://github.com/pyenv/pyenv#installation Run the following, replacing `PYTHON_VERSION` with your desired version. ``` pyenv install PYTHON_VERSION ``` #### Steps on Windows In windows, you can either use the bash shell and follow the directions above, or try [pyenv-win](https://github.com/pyenv-win/pyenv-win#installation). In the latter case, make sure to follow all the installation instructions, including the **Finish the installation**. Then proceed to follow the directions above to install a version of python matching `pyproject.toml`. Finally, you may then need to manually add that version of python to your path.


The first time you set up your development environment, you should follow these steps:

  1. Follow these instructions to install poetry.
-   https://python-poetry.org/docs/#installation
    -   Note 2022/06/21: you may ignore "This installer is deprecated". See
        [python-poetry/poetry/issues/4128](https://github.com/python-poetry/poetry/issues/4128)
  1. Install dependencies into a virtual environment with this command.

    poetry install

  2. Fetch a copy of the core pretext library and bundle templates by running

    poetry run python scripts/fetch_core.py

The last command above should also be run when returning to development after some time, since the core commit you develop against might have changed.

Make sure you are in a poetry shell during development mode so that you execute the development version of pretext-cli rather than the system-installed version.

pretext --version # returns system version poetry shell pretext --version # returns version being developed

When inside a poetry shell you can navigate to other folders and run pretext commands. Doing so will use the current development environment version of pretext. In newer versions of poetry, the shell command is not avaiable anymore and is a plugin instead. Alternatively, the command poetry env activate will print a line that you can then run to activate the virtual environment:

pretext --version # returns system version poetry env activate # returns something like `source ./venv/bin/activate`, which you should now run source .venv/bin/activate pretext --version # returns version being developed

Updating dependencies

Show instructions To add dependencies for the package, run ``` poetry add DEPENDENCY-NAME ``` If someone else has added a dependency: ``` poetry install ```

Using a local copy of PreTeXtBook/pretext

See docs/core_development.md.

Formatting code before a commit

All .py files are formatted with the black python formatter and checked by flake8. Proper formatting is enforced by checks in the Continuous Integration framework. Before you commit code, you should make sure it is formatted with black and passes flake8 by running the following commands (on linux or mac) from the root project folder (most likely pretext-cli).

poetry run black . poetry run flake8

Testing

Sets are contained in tests/. To run all tests:

poetry run pytest

To run a specific test, say test_name inside test_file.py:

poetry run pytest -k name

Tests are automatically run by GitHub Actions when pushing to identify regressions.

Packaging

To check if a successful build is possible:

poetry run python scripts/build_package.py

To publish a new alpha release, first add/commit any changes. Then the following handles bumping versions, publishing to PyPI, and associated Git management.

poetry run python scripts/release_alpha.py

Publishing a stable release is similar:

poetry run python scripts/release_stable.py # patch +0.+0.+1 poetry run python scripts/release_stable.py minor # +0.+1.0 poetry run python scripts/release_stable.py major # +1.0.0

Asset generation

Generating assets is complicated. See docs/asset-generation.md


About

PreTeXt-CLI Team

A note and special thanks

A pretext package unrelated to the PreTeXtBook.org project was released on PyPI several years ago by Alex Willmer. We are grateful for his willingness to transfer this namespace to us.

As such, versions of this project before 1.0 are released on PyPI under the name pretextbook, while versions 1.0 and later are released as pretext.

About PreTeXt

The development of PreTeXt's core is led by Rob Beezer.

Owner

  • Name: PreTeXt
  • Login: PreTeXtBook
  • Kind: organization

GitHub Events

Total
  • Create event: 187
  • Release event: 37
  • Issues event: 48
  • Watch event: 4
  • Delete event: 139
  • Issue comment event: 96
  • Push event: 346
  • Pull request review event: 24
  • Pull request review comment event: 20
  • Pull request event: 342
  • Fork event: 6
Last Year
  • Create event: 187
  • Release event: 37
  • Issues event: 48
  • Watch event: 4
  • Delete event: 139
  • Issue comment event: 96
  • Push event: 346
  • Pull request review event: 24
  • Pull request review comment event: 20
  • Pull request event: 342
  • Fork event: 6

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 900
  • Total Committers: 10
  • Avg Commits per committer: 90.0
  • Development Distribution Score (DDS): 0.388
Past Year
  • Commits: 213
  • Committers: 8
  • Avg Commits per committer: 26.625
  • Development Distribution Score (DDS): 0.535
Top Committers
Name Email Commits
Steven Clontz s****z@g****m 551
Oscar Levin o****n@u****u 259
GitHub Actions Bot 36
Bryan A. Jones b****s@e****u 27
dependabot[bot] 4****] 11
Jason Siefken s****j@g****m 7
Alex Jordan a****n@p****u 4
Dave Rosoff d****f@c****u 3
JeanSebastienTurcotte j****e@g****m 1
Christian Lawson-Perfect c****t@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 194
  • Total pull requests: 419
  • Average time to close issues: 4 months
  • Average time to close pull requests: 3 days
  • Total issue authors: 16
  • Total pull request authors: 15
  • Average comments per issue: 3.27
  • Average comments per pull request: 0.87
  • Merged pull requests: 381
  • Bot issues: 0
  • Bot pull requests: 76
Past Year
  • Issues: 15
  • Pull requests: 142
  • Average time to close issues: 4 days
  • Average time to close pull requests: about 13 hours
  • Issue authors: 7
  • Pull request authors: 9
  • Average comments per issue: 0.6
  • Average comments per pull request: 0.13
  • Merged pull requests: 123
  • Bot issues: 0
  • Bot pull requests: 43
Top Authors
Issue Authors
  • StevenClontz (78)
  • oscarlevin (63)
  • bjones1 (11)
  • siefkenj (11)
  • bnmnetp (9)
  • rbeezer (7)
  • Alex-Jordan (5)
  • davidaustinm (2)
  • rhinopotamus (2)
  • whaynes (1)
  • sean-fitzpatrick (1)
  • braughtg (1)
  • krtschil (1)
  • rpruim (1)
  • rhigginbottom (1)
Pull Request Authors
  • oscarlevin (235)
  • StevenClontz (128)
  • github-actions[bot] (103)
  • bjones1 (34)
  • dependabot[bot] (13)
  • siefkenj (9)
  • ascholerChemeketa (4)
  • bnmnetp (3)
  • dbrianwalton (3)
  • skiadas (3)
  • Tanaquil18 (2)
  • davidaustinm (2)
  • sean-fitzpatrick (2)
  • Alex-Jordan (1)
  • christianp (1)
Top Labels
Issue Labels
PROSE (12) Useful Error Messages (1)
Pull Request Labels
dependencies (13) PROSE (8)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 11,560 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 24
  • Total versions: 750
  • Total maintainers: 2
pypi.org: pretext

A package to author, build, and deploy PreTeXt projects.

  • Versions: 750
  • Dependent Packages: 0
  • Dependent Repositories: 24
  • Downloads: 11,560 Last month
Rankings
Dependent repos count: 3.0%
Downloads: 5.0%
Average: 8.8%
Forks count: 9.8%
Dependent packages count: 10.0%
Stargazers count: 16.0%
Maintainers (2)
Last synced: 10 months ago

Dependencies

.github/workflows/major.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/minor.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/nightly.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/patch.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/test-on-push.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
  • black ^22.12.0 develop
  • codechat-server ^0.2.9 develop
  • pytest ^7.0.0 develop
  • pytest-console-scripts ^1.3.1 develop
  • pytest-mock ^3.8.2 develop
  • GitPython ^3
  • PyPDF2 ~2.5
  • click ^8
  • click-log ^0.4
  • ghp-import ^2
  • lxml ^4.8
  • pdfCropMargins ~1.0.9
  • playwright ^1
  • python ^3.8.5
  • requests ^2
  • single-version ^1
  • watchdog ^2