Add inline annotations to check that files are self-consistent
Project description
Scrybe
A script to help keep your README up-to-date.
Scrybe is a Python script originally developed specifically to help me manage the releases of my Typst packages ([1], [2], [3]). The features it implements make it in theory applicable to other similar processes unrelated to Typst. The process of releasing a new package involves a lot of
- checking that README examples are up-to-date and compile,
- updating links in the README to point to static snapshots,
- changing version numbers in
typst.toml, imports, etc.
scrybe can't do that automatically, but it can make the process less error-prone
and less stressful by validating that it has been done correctly.
scrybe works by scanning the input file(s) to look for annotations (usually written in comments).
Examples
Validating links and versions
Let's say you have a link in your README, and it looks like this:
See the [documentation](docs/main.pdf).
Upon release of version 0.1.0, you want the link to now point to the snapshot
for the appropriate version.
We can add the following annotation:
<!-- @scrybe(if publish; grep https; grep {{version}}) -->
See the [documentation](docs/main.pdf).
i.e. this means: if the execution mode is publish, the line that follows must contain
the text "https" and it must contain the current version number.
Then invoke the command
scrybe README.md --publish --version=0.1.0
If you forgot to update the link you will get the following output:
Flags:
publish
version 0.1.0
Reading README.md
Checking command group at line 37
Guarded by publish (sat) proceed
Searching for pattern: https
ERROR: No match!
Searching for pattern: 0.1.0
ERROR: No match!
Update the link and now the annotation will pass
<!-- @scrybe(if publish; grep https; grep {{version}}) -->
See the [documentation](https://github.com/user/repo/tree/v0.1.0/docs.pdf).
Flags:
publish
version 0.1.0
Reading README.md
Checking command group at line 63
Guarded by publish (sat) proceed
Searching for pattern: https ok
Searching for pattern: 0.1.0 ok
Ensuring that examples compile
Consider now that your README contains the following example:
```typ
#import "@local/mypkg:0.1.0"
#mypkg.magic()
```
On release we want to ensure that
- it compiles
- it imports the published package
- it uses the latest version
Additionally outside of a release we want the import to point to @local
as that is where the dev version of the package would be copied.
Here are annotations that will check exactly that:
<!-- @scrybe(if publish; jump import; grep preview; grep {{version}}) -->
<!-- @scrybe(not publish; jump import; grep local; grep {{version}}) -->
<!-- @scrybe(jump import; until ```; diff examples/demo.typ) -->
```typ
#import "@local/mypkg:0.1.0"
#mypkg.magic()
```
The output is one of the following:
$ scrybe README.md --version=0.1.0
Flags:
version 0.1.0
Reading README.md
Checking command group at line 97
Guarded by publish (unsat) skip
Checking command group at line 98
Guarded by not publish (unsat) proceed
Start cursor forward until import selected: 101-101
Searching for pattern: local ok
Searching for pattern: 0.1.0 ok
Checking command group at line 99
Start cursor forward until import selected: 101-101
End cursor forward until ``` selected: 101-103
Diff to examples/demo.typ
< #import "/src/lib.typ" as mypkg
> #import "@local/mypkg:0.1.0
$ scrybe README.md --publish --version=0.1.0
Flags:
publish
version 0.1.0
Reading README.md
Checking command group at line 101
Guarded by publish (sat) proceed
Start cursor forward until import selected: 105-105
Searching for pattern: preview
ERROR: No match!
Searching for pattern: 0.1.0 ok
Checking command group at line 102
Guarded by not publish (sat) skip
Checking command group at line 103
Start cursor forward until import selected: 105-105
End cursor forward until ``` selected: 105-107
Diff to examples/demo.typ
< #import "/src/lib.typ" as mypkg
> #import "@local/mypkg:0.1.0"
In other words, in non-publish mode all looks good,
and before the package can be published the @local needs to be changed to @preview.
Final tip
I recommend adding a version check to your typst.toml, which is very easy:
[package]
name = "mypkg"
# @scrybe(not version; panic Please specify a version number)
# @scrybe(grep {{version}})
version = "0.1.0"
entrypoint = "src/lib.typ"
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 scrybe_check-0.1.0.tar.gz.
File metadata
- Download URL: scrybe_check-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7329f1649d8c75496eb85bcbfa2c0b05202706579678334ff713f6fac705b2e9
|
|
| MD5 |
315c066ffb2cfad0db53570e8e80ea79
|
|
| BLAKE2b-256 |
739e061333bede0799fb796bd625866ba7c40a07c98a7c0d4f45a5135f585f82
|
File details
Details for the file scrybe_check-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scrybe_check-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8995ffdac9768cc0c8d044a0b7a7cda13cbf151e8250420cf9203c4d88b6bc9b
|
|
| MD5 |
b10270dd85bcbfd79d2c849f7aa9647f
|
|
| BLAKE2b-256 |
ad38ada4dbae8750c666013bb723b97e0b05f0e4f591cd5fb260601a982dc1a0
|