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
WriteMetemplate 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:
WriteMemacros 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, language: str='python') -> RenderingInfo:
"""
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) -> RenderingInfo:
"""
Runs the command and captures stdout
"""
..
@_MainNamespace.register
def show_help_menu(cmd: str) -> RenderingInfo:
"""
Small wrapper around show_command_output; queries the help menu
"""
..
Status
WriteMe is under construction and not production-ready yet.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywriteme-0.3.0.tar.gz.
File metadata
- Download URL: pywriteme-0.3.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
297ebffaadd6eff78c8cae4a420233dc60d941e0241678c4523da7b8d453e483
|
|
| MD5 |
8b981966a425d735db3a1ceb467df9df
|
|
| BLAKE2b-256 |
9a66559c3e3f8b245732ebd72f7492c42e4947ac9f61f339d0bf0b3909705d4f
|
Provenance
The following attestation bundles were made for pywriteme-0.3.0.tar.gz:
Publisher:
publish-to-pypi.yml on Hedwyn/WriteMe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywriteme-0.3.0.tar.gz -
Subject digest:
297ebffaadd6eff78c8cae4a420233dc60d941e0241678c4523da7b8d453e483 - Sigstore transparency entry: 869614374
- Sigstore integration time:
-
Permalink:
Hedwyn/WriteMe@7574cde4103e013f47acfbe2baa1fe5e26c69304 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/Hedwyn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@7574cde4103e013f47acfbe2baa1fe5e26c69304 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pywriteme-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pywriteme-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82c62c2d4c779b3352f0ccd402f249701141e75fb2586e2a3fa94baed2a98d28
|
|
| MD5 |
a59cd60e367e892219620e1cefca3b01
|
|
| BLAKE2b-256 |
17d37d244c107381ace23fa200ea0645313e06a200e515773f7f21db33c8b461
|
Provenance
The following attestation bundles were made for pywriteme-0.3.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on Hedwyn/WriteMe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywriteme-0.3.0-py3-none-any.whl -
Subject digest:
82c62c2d4c779b3352f0ccd402f249701141e75fb2586e2a3fa94baed2a98d28 - Sigstore transparency entry: 869614376
- Sigstore integration time:
-
Permalink:
Hedwyn/WriteMe@7574cde4103e013f47acfbe2baa1fe5e26c69304 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/Hedwyn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@7574cde4103e013f47acfbe2baa1fe5e26c69304 -
Trigger Event:
push
-
Statement type: