Skip to main content

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 bare SPDX-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 - propName entry followed by a - type: ... sub-line; specmd uses - propName: (trailing colon, no type: 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 as rdfs: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, and relationshipClass sub-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: example and sinceVersion are 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

specmd-0.1.0.tar.gz (75.9 kB view details)

Uploaded Source

Built Distribution

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

specmd-0.1.0-py3-none-any.whl (56.6 kB view details)

Uploaded Python 3

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

Hashes for specmd-0.1.0.tar.gz
Algorithm Hash digest
SHA256 65166d14f84e86dedc47849ec30e5db1466a82547688b25fd05cd37af4966d83
MD5 9f1a33c188a4c99fb414c763c0b7d5ee
BLAKE2b-256 679ecccc842b6e972efb6a00c6a8103b073906fd16b455c01c72cd8252dbe87e

See more details on using hashes here.

Provenance

The following attestation bundles were made for specmd-0.1.0.tar.gz:

Publisher: pypi-publish.yml on bact/specmd

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

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

Hashes for specmd-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79e3ace1f92a6a31cc6a82ff141251f1046e99d0ea10b163d2277bd5231ab24a
MD5 5ee2fc32c1f63d9a94d711e590974291
BLAKE2b-256 7adc3e009d7f6f74953293105b1f9678e0053817c65a75759266e7a5a83d1d7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for specmd-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on bact/specmd

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