Skip to content

Commit b652be8

Browse files
committed
Updates to docs content and tone
1 parent 521cd78 commit b652be8

6 files changed

Lines changed: 75 additions & 32 deletions

File tree

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
html_theme_options = {
5151
"color_mode": "light",
5252
"accent_color": "violet",
53-
"github_url": "https://github.com/StructuralPython/yamlreports",
53+
"github_url": "https://github.com/StructuralPython/ymprint",
5454
"nav_links": [
5555
{"title": "Quickstart", "url": "quickstart"},
5656
{"title": "Blocks", "url": "reference/blocks"},
@@ -61,7 +61,7 @@
6161
html_context = {
6262
"source_type": "github",
6363
"source_user": "StructuralPython",
64-
"source_repo": "yamlreports",
64+
"source_repo": "ymprint",
6565
}
6666

6767
pygments_style = "friendly"

docs/installation.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
YMPrint requires **Python 3.14 or newer**.
44

5+
## With pip
6+
7+
```bash
8+
pip install ymprint
9+
```
10+
511
## With `uv` (recommended)
612

713
[`uv`](https://docs.astral.sh/uv/) is the fastest way to install and run YMPrint as a tool:
@@ -43,16 +49,17 @@ Installing YMPrint pulls in everything needed to render PDFs:
4349

4450
| Dependency | Role |
4551
| --- | --- |
46-
| `reportlab` | The PDF layout engine that typesets your story. |
47-
| `pymupdf` / `pypdf` | Read PDF backgrounds, fill form fields, overlay content. |
52+
| `reportlab` | The PDF layout engine that typesets your document. |
53+
| `pymupdf` | Read PDF backgrounds, fill form fields, overlay content. |
4854
| `jinja2` | Interpolate `_vars` into your content. |
55+
| `wenmode` | Parses inline markdown (the latest library from lepture!) |
4956
| `pydantic` | Validate the document, style, and table configuration. |
5057
| `pygments` | Syntax highlighting for `_code` and `_py` blocks. |
5158
| `ruamel-yaml` | Parse your report YAML. |
5259
| `typer` | The `ym` command-line interface. |
5360

5461
A set of fonts is bundled with YMPrint, so documents render consistently on any machine
55-
without installing system fonts. See the [Fonts reference](reference/fonts.md).
62+
without needing to rely on system fonts (which may or may not load easily into ReportLab). See the [Fonts reference](reference/fonts.md).
5663

5764
:::{tip}
5865
`matplotlib` is **not** a hard dependency. Install it in the same environment only if you
@@ -62,9 +69,15 @@ plan to use the [`_matplotfig`](#block-matplotfig) block.
6269
## Live preview (optional)
6370

6471
The [`ym live`](reference/cli.md#ym-live) command opens the rendered PDF in the
65-
[Okular](https://okular.kde.org/) document viewer and hot-reloads it on every save. If you
72+
[Okular](https://okular.kde.org/) document viewer which hot-reloads your PDF on every save.
73+
74+
The Okular PDF viewer is available for _every_ desktop platform (Windows, Mac, and many flavours of Linux).
75+
76+
If you
6677
want to use live mode, install Okular through your system package manager, for example:
6778

6879
```bash
6980
sudo apt install okular # Debian / Ubuntu
7081
```
82+
83+
If you are on Windows, you can install Okular with Winget or with the Windows store.

docs/quickstart.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ This walkthrough takes you from an empty folder to a rendered PDF.
44

55
## 1. Write a report
66

7-
Create a file called `report.yml`. The **top-level keys are your headings**, and their
8-
values are the content underneath them.
7+
Create a file called `report.yml` (or, you know, something meaningful to you).
8+
9+
The **top-level keys are your headings**, and their
10+
values are the content (paragraphs or otherwise) underneath them.
11+
12+
See the example below:
913

1014
```yaml
1115
Site inspection report:
@@ -53,6 +57,8 @@ destination:
5357
ym convert report.yml output/inspection.pdf
5458
```
5559

60+
The output directory(ies) will be created if the do not already exist.
61+
5662
## 3. Iterate live (optional)
5763

5864
While drafting, run [`ym live`](reference/cli.md#ym-live) to open the PDF and rebuild it
@@ -63,7 +69,7 @@ ym live report.yml
6369
```
6470

6571
Leave it running in a terminal, edit `report.yml` in your editor, and the preview refreshes
66-
on save. Press `Ctrl+C` to stop.
72+
on save. Press `Ctrl+C` to stop (which will also close the attached Okular instance).
6773

6874
## 4. Style it
6975

docs/reference/blocks.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ others extend it (admonitions, styled horizontal rules, executable Python).
77
## Block syntax
88

99
A block is a **key that begins with an underscore**, e.g. `_img` or `_spacer`. Its value is
10-
a block-specific data structure — sometimes a scalar, sometimes a mapping of parameters.
10+
a block-specific data structure, typically either a scalar or a mapping that allows several arguments to be passed.
11+
1112
Blocks appear wherever content is allowed, typically as list items:
1213

1314
```yaml
@@ -20,23 +21,25 @@ Report:
2021
- _pagebreak:
2122
```
2223
23-
Some block codes accept a **suffix** after the underscore code, e.g. `_hrule_red` and
24+
All block codes accept an optional, user-defined **suffix** after the underscore code, e.g. `_hrule_red` and
2425
`_hrule_blue` are both handled by the `_hrule` block — the suffix simply keeps the YAML keys
25-
unique when you use several in one list.
26+
unique when you use several in one list and allows you to meaningfully identify them if you are using several in a row.
27+
28+
The suffix does not affect how the block is executed. It is simply an optional identifier.
2629

2730
## Block catalogue
2831

2932
| Block | Purpose |
3033
| --- | --- |
31-
| [`_img`](#block-img) | Embed an image with a caption. |
32-
| [`_matplotfig`](#block-matplotfig) | Embed a matplotlib figure object. |
34+
| [`_img`](#block-img) | Embed an image with an optional caption. |
35+
| [`_matplotfig`](#block-matplotfig) | Embed a matplotlib figure object with an optional caption. |
3336
| [`_info` / `_warning` / `_danger` / `_tip` / `_note`](#block-admonitions) | Callout boxes. |
3437
| [`_blockquote`](#block-blockquote) | A quotation with attribution. |
35-
| [`_code`](#block-code) | A non-executable, syntax-highlighted code block. |
36-
| [`_py`](#block-py) | Execute Python and optionally show the source. |
37-
| [`_loadjson`](#block-loadjson) | Load variables from a JSON file. |
38+
| [`_code`](#block-code) | A non-executable code block. |
39+
| [`_py`](#block-py) | Execute Python and optionally show the syntax-highlighted source. |
40+
| [`_loadjson`](#block-loadjson) | Load variables into the document from a JSON file. |
3841
| [`_pagebreak`](#block-pagebreak) | Force a page break. |
39-
| [`_hrule`](#block-hrule) | A configurable horizontal rule. |
42+
| [`_hrule`](#block-hrule) | A customizable horizontal rule. |
4043
| [`_spacer`](#block-spacer) | Insert vertical whitespace. |
4144

4245
---
@@ -86,7 +89,7 @@ Report:
8689
| --- | --- | --- | --- |
8790
| `fig` | ✅ | — | A matplotlib `Figure`, passed as `$var`. |
8891
| `caption` | | `""` | Caption text shown below the figure. |
89-
| `scale_ratio` | | `0.8` | Scale factor relative to the available content width. |
92+
| `scale_ratio` | | `0.8` | Scale factor relative to the available content width. The figure image is automatically shrunk to fit the frame if it would overflow.|
9093

9194
:::{note}
9295
`matplotlib` is an optional dependency — install it in the same environment as YMPrint to
@@ -141,7 +144,7 @@ _blockquote:
141144
(block-code)=
142145
## `_code` — Preformatted code
143146

144-
A **non-executable**, syntax-highlighted code block. Use this to display code or config
147+
A **non-executable**, code block for pre-formatted text. Use this to display code or config
145148
verbatim.
146149

147150
```yaml
@@ -157,6 +160,9 @@ _code:
157160
| Parameter | Required | Meaning |
158161
| --- | --- | --- |
159162
| `source` | ✅ | The literal text to display. Use a YAML block scalar (`|`) to preserve line breaks. |
163+
| `line_numbers` | | — | Show line numbers alongside the rendered source. |
164+
| `caption` | | — | Caption shown with the rendered code. |
165+
| `width_ratio` | | `0.75` | Width of the rendered code block relative to the content width. |
160166

161167
To **run** code instead of just showing it, use [`_py`](#block-py).
162168

@@ -183,6 +189,14 @@ _py:
183189
c = math.sin(a / b)
184190
```
185191

192+
:::{note}
193+
The `|` after `source:` tells the YAML parser that this is preformatted text, to respect the line breaks exactly as written, and that text should not be wrapped.
194+
195+
This is in contrast to the `>` character, often used when writing paragraph content, which allows you to break lines wherever you want in the YAML without breaking lines in the finished document.
196+
197+
Both the `|` and `>` character are part of the YAML spec.
198+
:::
199+
186200
| Parameter | Required | Default | Meaning |
187201
| --- | --- | --- | --- |
188202
| `source` | ✅ | — | Python source to execute. |
@@ -194,7 +208,9 @@ _py:
194208

195209
:::{warning}
196210
`_py` runs `exec()` in the **same** Python environment as YMPrint. External subprocess
197-
isolation is not currently implemented — only run documents you trust.
211+
isolation is not currently implemented. Only run documents you trust.
212+
213+
YMPrint is **not** intended to be operated as a public-facing web app.
198214
:::
199215

200216
After execution the variables are usable everywhere:
@@ -292,5 +308,9 @@ Report:
292308
- There is a 20 pt spacer above.
293309
```
294310

295-
The value is the height of the space in points. A `_spacer: 0` is a handy trick to stop a
311+
The value is the height of the space in points.
312+
313+
:::{tip}
314+
A `_spacer: 0` is a handy trick to stop a
296315
paragraph being misinterpreted as a bullet when it's immediately followed by a list.
316+
:::

docs/reference/cli.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ym --help
99
| Command | What it does |
1010
| --- | --- |
1111
| [`ym convert`](#ym-convert) | Render a YAML file to a PDF once. |
12-
| [`ym live`](#ym-live) | Render, open the PDF, and hot-reload on every save. |
12+
| [`ym live`](#ym-live) | Render, open the PDF in Okular, which will hot-reload on every save. |
1313

1414
## `ym convert`
1515

@@ -23,7 +23,7 @@ ym convert SRC [DEST] [--config-dir DIR]
2323
| --- | --- | --- |
2424
| `SRC` || Path to the source YAML report. |
2525
| `DEST` | | Output PDF path. Defaults to the source path with a `.pdf` extension, written next to the source file. |
26-
| `--config-dir` | | Directory holding a project config file. If omitted, YMPrint searches parent directories for one. |
26+
| `--config-dir` | | Directory holding a project config file. If omitted, YMPrint searches parent directories for one. If a config file is not found in the parent directories, the internal default configuration will take priority. |
2727

2828
**Examples**
2929

@@ -47,7 +47,9 @@ On success it prints the resolved output path:
4747
## `ym live`
4848

4949
Render the PDF, open it in the [Okular](https://okular.kde.org/) viewer, and rebuild
50-
automatically whenever the source (or a watched config file) changes. Ideal for drafting.
50+
automatically whenever the source (or the non-default config file) changes.
51+
52+
Ideal for live authoring.
5153

5254
```bash
5355
ym live SRC [DEST] [--config-dir DIR]
@@ -60,7 +62,7 @@ ym live SRC [DEST] [--config-dir DIR]
6062
| `--config-dir` | | Directory of config files to also watch for changes. |
6163

6264
**What it watches.** Live mode watches the source file and, if a config directory is in
63-
play, the config files within it (`doctemplate.yml`, `textstyles.yml`, `tablestyles.yml`).
65+
play, the config files within it (`config.ymprint.yml`.
6466
When any of them changes, the PDF is re-rendered and Okular refreshes.
6567

6668
```bash
@@ -82,7 +84,7 @@ example `sudo apt install okular` on Debian/Ubuntu). See
8284
## Config discovery
8385

8486
When you don't pass `--config-dir`, YMPrint walks **up** from the current working directory
85-
looking for a config file (a `*.ymprint.yml` project config, or the individual
86-
`doctemplate.yml` / `textstyles.yml` / `tablestyles.yml` files). The nearest match is used.
87-
This lets a whole tree of documents share one project style. See
87+
looking for a config file (a `*.ymprint.yml` project config). The nearest match is used.
88+
89+
This enables a whole tree of documents to share one project style. See
8890
[Configuration](../guide/configuration.md).

docs/reference/fonts.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Fonts reference
22

3-
YMPrint **bundles** a set of font families so your documents render identically on any
3+
YMPrint **bundles** a select set of font families so your documents render identically on any
44
machine — no system font installation required. Reference a family by name in
55
[`_style`](#cfg-style).
66

@@ -16,7 +16,7 @@ _style:
1616
1717
The name is the family name (case-sensitive). Each bundled family ships with regular, bold,
1818
italic, and bold-italic variants, so **bold** and *italic* inline formatting render
19-
correctly.
19+
correctly.
2020
2121
## Bundled families
2222
@@ -38,13 +38,15 @@ correctly.
3838

3939
## Standard PDF fonts
4040

41-
The built-in defaults also use the standard PDF core fonts such as `Helvetica`, which are
41+
The built-in defaults also use the standard PDF core fonts (Helvetica, Times, and Courier), which are
4242
always available. You can name them directly:
4343

4444
```yaml
4545
_style:
4646
body:
4747
font: Helvetica
48+
headings:
49+
font: Times
4850
```
4951

5052
## Inline code font

0 commit comments

Comments
 (0)