Skip to main content

Parser for converting python docstrings to .astro files for the Astro static site generator.

Project description

Yapper

Yapper converts Python docstrings to astro files for use by the Astro static site generator.

It uses griffe to parse python modules and extracts numpy style docstrings.

It is up to the user to maintain consistency between types specified in signatures and docstrings. Differences betweten the two can be preferable where docstrings represent simplified forms of typing information than might otherwise be necessary for function signatures.

Docstrings and parameter descriptions will be passed through as a raw markdown wrapped in the Astro <Markdown is:raw></Markdown> elements.

Class and function elements are wrapped with html with css classes that can be styled from Astro.

See the cityseer.benchmarkurbanism.com documentation site and associated docs repo for a working example.

Conversion of markdown formatting, code blocks, admonitions, etc., is all handled downstream by Astro. Styling is likewise handled downstream via css targeting the associated element classes.

Configuration

Configuration is provided in pyproject.toml file placed in the current directory, else a --config parameter can be provided with a relative or absolute filepath to a toml config file.

yapper --config ./custom_config.toml

The toml file must include a [tool.yapper] section, with keys corresponding to the default configuration options:

[tool.yapper]
package_root_relative_path = './'
intro_template = """
---\n
import { Markdown } from 'astro/components';\n
---\n
"""
outro_template = ""
module_map = [
  { module = "test.mock_file", astro = "./tests/mock_default.astro" },
]

If you want to wrap the .astro output in a particular layout, then set the intro_template and outro_template accordingly, for example, the following will import the PageLayout layout and will wrap the generated content accordingly:

[tool.yapper]
package_root_relative_path = './'
intro_template = """
---\n
import { Markdown } from 'astro/components';\n
import PageLayout from '../layouts/PageLayout.astro'\n
---\n
\n
<PageLayout>
"""
outro_template = """
</PageLayout>\n
"""
module_map = [
  { module = "test.mock_file", py = "./tests/mock_file.py", astro = "./tests/mock_default.astro" },
]

The module_map is mandatory and specifies the names of the python modules to be processed via the module key and an astro key corresponding to the output file:

Development

yapper uses a pyproject.toml file to specify project dependencies and scripts related to project development and publishing.

See pyproject.toml for available scripts.

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

yapper-0.4.1.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

yapper-0.4.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file yapper-0.4.1.tar.gz.

File metadata

  • Download URL: yapper-0.4.1.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for yapper-0.4.1.tar.gz
Algorithm Hash digest
SHA256 6df275c280fb674547200ff781c4aedd22a6056de543d338d77419f0e6b9fd4d
MD5 d4b13fd56fa915ecb2021c4a08f2d6e1
BLAKE2b-256 b363206f65609c29b2aa8c4f34f3d55829f7d129dfb56c6d342784be46f6d2bd

See more details on using hashes here.

File details

Details for the file yapper-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: yapper-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for yapper-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5988c24123c0f7556897a788ff9793e4f32f31066e8091b6745b0070836653fc
MD5 8bb717fca1fc369dfd1e89d72802d76c
BLAKE2b-256 da4a61840f8f7310e14b48d1d63fafafcd7fc20404fcd14c6209c52538d22f57

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page