Parse Markdown model definitions into RDF, diagrams, and docs.
Project description
specmd
Parse Markdown model definitions into RDF, diagrams, and docs.
Functionality
specmd always reads and validates the complete model directory. It can then generate one or more of the following outputs:
| Format | Description |
|---|---|
jsondump |
JSON dump of the parsed model |
mkdocs |
MkDocs source files for website generation |
plantuml |
PlantUML diagram source |
rdf |
OWL+SHACL ontology and JSON-LD context |
tex |
TeX source for printable specification |
singlefile |
Single Markdown file (Pandoc → Word) |
webpages |
Per-IRI web pages (not yet implemented) |
Installation
pip install specmd
Usage
specmd uses subcommands:
specmd <command> [options]
Commands:
generate (gen) Generate output artefacts from a model directory
validate Validate a model directory without generating output
migrate Convert spec-parser format to specmd format
export Export a specmd model to another format
Validate
Check that a model directory is correctly formatted:
specmd validate path/to/model
Generate
Generate all output formats into subdirectories under ./out/:
specmd generate path/to/model --output ./out
Generate specific formats only:
specmd generate path/to/model --formats rdf,mkdocs --output ./out
Override the output directory for a single format:
specmd generate path/to/model --output ./out --rdf-dir ./ontology
Available formats:
jsondump, mkdocs, plantuml, rdf, tex, singlefile, webpages.
Migrate
Convert a model written in the spec-parser format to specmd format:
specmd migrate path/to/old-model --output path/to/new-model
Export
Export a specmd model back to the spec-parser format:
specmd export path/to/model --output path/to/exported --format legacy
Common options
| Option | Commands | Description |
|---|---|---|
-o/--output DIR |
generate, migrate, export |
Output directory |
-f/--force |
generate, migrate, export |
Overwrite existing output |
-q/--quiet |
all | Warnings and errors only |
-v/--verbose |
all | Debug output |
-V/--version |
top-level | Show version and exit |
Full help:
specmd --help
specmd generate --help
Prerequisites
All Python dependencies are installed automatically with pip install specmd.
External tools required for specific formats:
| Format | External prerequisite |
|---|---|
tex |
pandoc |
singlefile |
pandoc |
| All others | None |
spec-parser compatibility
A main.py compatibility shim is provided for existing CI/scripts that
invoke the spdx/spec-parser CLI.
It accepts spec-parser's original command-line arguments, internally runs
specmd migrate on the input, then specmd generate or specmd validate.
Simply replace python spec-parser/main.py with python specmd/main.py in
existing workflows.
History
specmd is built on the design of spdx/spec-parser, with a goal of being a drop-in replacement. Several features originate from proposals that were filed as issues or submitted as pull requests there but never merged.
The Markdown input format is nearly identical, with the following changes:
- Front matter is now a standard
----delimited YAML block. spec-parser used a bareSPDX-License-Identifier:line before the first heading -- non-standard Markdown and flagged by markdownlint. - Section headings are read case-insensitively; specmd normalises them at parse time. spec-parser required exact Title Case.
- Properties section format changed: spec-parser used a bare
- propNameentry followed by a- type: ...sub-line; specmd uses- propName:(trailing colon, notype:line). Aligned with YAML format (allowed us to use PyYAML to handle this without the need of custom parser) and less typing/less error-prone. - Format section values are now backtick-wrapped
(e.g.
- pattern: `regex`), to allow correct display in Markdown (e.g. when review it on GitHub "preview" view). - Metadata keys are now camelCase (e.g.
subClassOf) instead of Title Case or custom casing (e.g.SubclassOf), aligning with standard vocabulary terms such asrdfs:subClassOf. - Instantiability field replaced: spec-parser used
- Instantiability: Abstract; specmd uses- abstract: true. - Deprecation information (
deprecated,deprecatedVersion,isReplacedBy) moved from inline bold prose in the Description section to structured metadata fields, with corresponding RDF/OWL predicates. - Vocabulary entries support a structured format with
from,to, andrelationshipClasssub-fields for relationship type vocabularies, extracted automatically from prose descriptions during migration. This information enables SHACL validation rules and enables specialised rendering of relationship types on the specification website (future work). - New metadata fields:
exampleandsinceVersionare supported across all element types.
Models written in the original spec-parser format
(such as spdx/spdx-3-model)
can be converted to specmd format using specmd migrate.
specmd models can be converted back using specmd export --format legacy.
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 specmd-0.1.0.tar.gz.
File metadata
- Download URL: specmd-0.1.0.tar.gz
- Upload date:
- Size: 75.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65166d14f84e86dedc47849ec30e5db1466a82547688b25fd05cd37af4966d83
|
|
| MD5 |
9f1a33c188a4c99fb414c763c0b7d5ee
|
|
| BLAKE2b-256 |
679ecccc842b6e972efb6a00c6a8103b073906fd16b455c01c72cd8252dbe87e
|
Provenance
The following attestation bundles were made for specmd-0.1.0.tar.gz:
Publisher:
pypi-publish.yml on bact/specmd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
specmd-0.1.0.tar.gz -
Subject digest:
65166d14f84e86dedc47849ec30e5db1466a82547688b25fd05cd37af4966d83 - Sigstore transparency entry: 1573900639
- Sigstore integration time:
-
Permalink:
bact/specmd@ee606ccba43b3a378f2fe0a300aedaa2fc1fa122 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bact
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@ee606ccba43b3a378f2fe0a300aedaa2fc1fa122 -
Trigger Event:
release
-
Statement type:
File details
Details for the file specmd-0.1.0-py3-none-any.whl.
File metadata
- Download URL: specmd-0.1.0-py3-none-any.whl
- Upload date:
- Size: 56.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79e3ace1f92a6a31cc6a82ff141251f1046e99d0ea10b163d2277bd5231ab24a
|
|
| MD5 |
5ee2fc32c1f63d9a94d711e590974291
|
|
| BLAKE2b-256 |
7adc3e009d7f6f74953293105b1f9678e0053817c65a75759266e7a5a83d1d7d
|
Provenance
The following attestation bundles were made for specmd-0.1.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on bact/specmd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
specmd-0.1.0-py3-none-any.whl -
Subject digest:
79e3ace1f92a6a31cc6a82ff141251f1046e99d0ea10b163d2277bd5231ab24a - Sigstore transparency entry: 1573900653
- Sigstore integration time:
-
Permalink:
bact/specmd@ee606ccba43b3a378f2fe0a300aedaa2fc1fa122 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bact
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@ee606ccba43b3a378f2fe0a300aedaa2fc1fa122 -
Trigger Event:
release
-
Statement type: