Skip to main content

Templating engine for README and other markdown files

Project description

WriteMe

WriteMe is a CLI tool for painless templating of README or other markdown files. Ever been tired of copy-pasting snippets of code, command-outputs, and other dynamic-ish things for which your README itself is not the source of truth ? That's where writeme comes in. Create a WRITEME.md file, write your README template in there and let WriteMe autogenerate your README, so that your README is always in sync with your project.

Not yet-another-templating-language

One of the main pain point with standard templating solutions is that they have to define their own custom syntax, which then gets plugged into some arbitrary other format (HTML, Javascript, or even C, you call it) in ways that look extremly ugly most of the time. This leads to some tangled mess in the template files themselves (which become incomprehensible by linters/LSPs, thus harder to read and check for human developers), on top of having to learn of whole new syntax solely for the templating needs.
This is particularly bad for Markdown, which is format that has been designed to be fairly readable even before rendering, and also to be simple to use.
To tackle this problem, WriteMe is designed as follows:

  • A WriteMe template file is still 100% valid markdown, and your markdown LSP/linters will work properly on them. The macros used for markdown generation are always guarded in code fences, making them isolated and easy to read by design.
  • There's little to no custom syntax: WriteMe macros are python code, which get replaced by their output after rendering.

Usage

Calling writeme from command-line

This project is self-hosted, meaning that this README is generated using WriteMe. The template file used to generate this README is located at the root of this repo, in WRITEME.md. You can render a WriteMe template using the writeme render command:

Welcome to WriteMe !
Usage: writeme render [OPTIONS] MARKDOWN_PATH

  Renders a WriteMe template. Formats all found `writeme` code blocks in the
  passed markdown file. Output is written the the file given by -o if passed,
  and to stdout otherwise.

Options:
  -o, --output TEXT               Path to the file to render to. If omitted,
                                  uses stdout
  -mxl, --max-line-length INTEGER
                                  Maximum line length to apply when formatting
                                  Markdown
  -norm, --normalize-whitespaces  Normalizes whitespaces
  --help                          Show this message and exit.

Actually writing the template file

WriteMe generation macros should be wrapped in code fences, using the writeme as the language. You can refer to WRITEME.md for examples.
The syntax within the code blocks is pure Python; the function called will be replaced by its output in the rendered file. Available functions are as follows:

@_MainNamespace.register
def show_source_code(import_path: str, declaration_only: bool=False) -> str:
    """
    Displays the source code on the object at `import_path`

    Parameters
    ----------
    obj_import_path: str
        Path to the object from which to display the source code,
        as {import_path}:func_name.

    decl_only: bool
        Only shows the function (or class declaration), removes the body
        (show ... (Ellipsis) instead)
    """
    ..
@_MainNamespace.register
def show_command_output(cmd: str) -> str:
    """
    Runs the comamnd and captures stdout
    """
    ..
@_MainNamespace.register
def show_help_menu(cmd: str) -> str:
    """
    Small wrapper around show_command_output; queries the help menu
    """
    ..

Status

WriteMe is under construction and not production-ready yet.

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

pywriteme-0.2.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywriteme-0.2.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pywriteme-0.2.3.tar.gz.

File metadata

  • Download URL: pywriteme-0.2.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pywriteme-0.2.3.tar.gz
Algorithm Hash digest
SHA256 fe758c527737cd912281b19b63776c8d03093339e031060c96c59c022f4241a9
MD5 d4562fd0197d0315f325d005a148b239
BLAKE2b-256 200c313e6c5c72dafd15b89ca6239eb519faaa03b6ec2cb20034881b0c9d2cd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywriteme-0.2.3.tar.gz:

Publisher: publish-to-pypi.yml on Hedwyn/WriteMe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pywriteme-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pywriteme-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pywriteme-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6a10832f1194472ff7631e1dced71e251663d24ad3152922b582d1c31a15b7d6
MD5 183124c2991e01a74bbd821c85600002
BLAKE2b-256 b1823daad96b0b026e139c3a7d215c63436f17ef018a0f7a67498591ccdf28b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywriteme-0.2.3-py3-none-any.whl:

Publisher: publish-to-pypi.yml on Hedwyn/WriteMe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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