Skip to main content

Transclusion for Spec-as-Source Development

Project description

syncspec

Transclusion for Spec-as-Source Development

Syncspec enables bidirectional content embedding between files, allowing you to maintain specifications and source code in sync.

Installation

Install the CLI tool from PyPI:

pip install syncspec

## Quick start

Run syncspec in your working directory:

```bash
syncspec .

The tool recursively processes all files in the specified directory.

Ignore files and directories

Create a rules file in .gitignore format to exclude specific paths. By default, syncspec looks for .syncspec_ignore in the working directory.

Example .syncspec_ignore file:

# Ignore Python cache and virtual environment
__pycache__/
.venv/
.git/
.pytest_cache/

# Ignore Python source files and build output
*.py
dist/

Import directive

Embeds content from another file into the current file.

Behavior:

  • Paths are relative to the receiving file
  • Files must be within the working directory
  • Imports are idempotent (only updates when source changes)

Example:

<!-- {- import="src/syncspec/dummy.py" -} -->
from dataclasses import dataclass

@dataclass
class Dummy:
    pass
<!-- {--} -->

Export directive

Writes content from the current file to an external file.

Example:

<!-- {- export="packge_info.md" -} -->
- The function is part of the python package `src/syncspec` .   
- Imports from the package take the form `from syncspec.x import X`.
- Assume Python version 3.9.
<!-- {--} -->

Source and Include directives

These directives work like export and import but operate on named content blocks without creating files.

Use cases:

  • source: Define reusable content blocks
  • include: Reference defined content blocks
<!-- {- source="explain" -} -->
## Explain the solution  

- Describe logical inconsistencies in the function specification
- Suggest improvements
- List unstated assumptions
<!-- {--} -->
<!-- {- include="explain" -} -->
## Explain the solution  

- Describe logical inconsistencies in the function specification
- Suggest improvements
- List unstated assumptions
<!-- {--} -->

Head and tail

Control how many lines to skip from the beginning (head) or end (tail) of imported content.

Example - Skip first 2 and last 2 lines:

<!-- {- import="src/syncspec/dummy.py", head=2, tail=2 -} -->
```python
from dataclasses import dataclass

@dataclass
class Dummy:
    pass
```
<!-- {--} -->

Safety

  • Idempotent operations: Running the same directive multiple times only updates content when the source has changed.
  • Relative paths: All file paths are relative to the file containing the directive.
  • Working directory: All imported/exported files reside within the working directory.

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

syncspec-0.1.2.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

syncspec-0.1.2-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file syncspec-0.1.2.tar.gz.

File metadata

  • Download URL: syncspec-0.1.2.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for syncspec-0.1.2.tar.gz
Algorithm Hash digest
SHA256 af73cee88e15bd837a1212a22aa6bff5cc555e29c327f5dd371e917f93395389
MD5 fa21a41fbca1b5064f7659a1d2f0f78f
BLAKE2b-256 38bcc239f1a610d479475f4923ea6d4edfaec64ec37789a03e93716c0016ce22

See more details on using hashes here.

File details

Details for the file syncspec-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: syncspec-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for syncspec-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 20860f4f9b1be3863f4f45e017c173f6fa8d1308a54696fab971207e5f10fe05
MD5 58c20c0d1e54b1ce7e4cf648a2012484
BLAKE2b-256 fb9e8a327753c25efd0e1204cc267e94f2d93e4248d38d5df3e5d355ee949197

See more details on using hashes here.

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