Skip to main content

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.

Metadata

Release files for syncspec 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for syncspec 0.1.2
File Size Uploaded
syncspec-0.1.2.tar.gz 17.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for syncspec 0.1.2
File Interpreter ABI Platform
syncspec-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 36.5 kB

Release files / syncspec-0.1.2.tar.gz

Download URL syncspec-0.1.2.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
af73cee88e15bd837a1212a22aa6bff5cc555e29c327f5dd371e917f93395389
BLAKE2b-256 checksum
How to use checksums
38bcc239f1a610d479475f4923ea6d4edfaec64ec37789a03e93716c0016ce22
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / syncspec-0.1.2-py3-none-any.whl

Download URL syncspec-0.1.2-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20860f4f9b1be3863f4f45e017c173f6fa8d1308a54696fab971207e5f10fe05
BLAKE2b-256 checksum
How to use checksums
fb9e8a327753c25efd0e1204cc267e94f2d93e4248d38d5df3e5d355ee949197
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page