Skip to main content

JSON <-> STRICTDOC Feature-Complete Parser & Converter

Parser e convertitore bidirezionale feature-complete tra JSON e StrictDoc (.sdoc / .sgra), conforme al 100% alla specifica grammaticale e semantica ufficiale di StrictDoc.

Funzionalità Supportate

  • Conversione Bidirezionale:
    • JSON -> SDOC (.json $\to$ .sdoc)
    • SDOC -> JSON (.sdoc $\to$ .json)
    • SGRA <-> JSON (.sgra $\leftrightarrow$ .json per grammatiche standalone)
    • Migrazione/Formattazione SDOC -> SDOC (da sintassi legacy [SECTION]/[FREETEXT] a sintassi moderna [[SECTION]]/[TEXT])
  • Copertura Completa della Specifica StrictDoc:
    • Header & Configurazione [DOCUMENT]: MID, TITLE, UID, VERSION, DATE, CLASSIFICATION, PREFIX / REQ_PREFIX, ROOT
    • Blocco OPTIONS: ENABLE_MID, RELATION_FIELD, MARKUP (RST, Text, HTML, Markdown), AUTO_LEVELS (On, Off), LAYOUT (Default, Website), VIEW_STYLE (Plain, Inline, Simple, Narrative, Table, Zebra), NODE_IN_TOC, DEFAULT_VIEW
    • Blocco METADATA: coppie chiave-valore personalizzate
    • Blocco VIEWS: definizione completa di viste (ID, NAME, TAGS $\to$ OBJECT_TYPE $\to$ VISIBLE_FIELDS con NAME e PLACEMENT, HIDDEN_TAGS)
    • Blocco [GRAMMAR]: sia IMPORT_FROM_FILE sia ELEMENTS completi di PROPERTIES (IS_COMPOSITE, PREFIX, VIEW_STYLE), FIELDS (String, Tag, SingleChoice(...), MultipleChoice(...), HUMAN_TITLE, REQUIRED) e RELATIONS (Parent, Child, File con ROLE e REVERSE_ROLE)
    • Nodi del Documento:
      • Nodi compositi moderni [[SECTION]] ... [[/SECTION]] e [[CUSTOM_NODE]] ... [[/CUSTOM_NODE]]
      • Nodi standard [TEXT], [REQUIREMENT] e qualsiasi nodo custom definito nella grammatica
      • Campi single-line e multi-line (>>> ... <<<) con ordinamento automatico dei campi secondo la grammatica attiva e supporto per campi COMMENT multipli
      • Inclusione frammenti [DOCUMENT_FROM_FILE]
      • Elementi inline nel testo: [LINK: UID] e [ANCHOR: UID, Title]
    • Relazioni (RELATIONS:): Parent, Child e File (ROLE, FORMAT, PATH, VALUE, ELEMENT, ID, LINE_RANGE, FUNCTION, CLASS, HASH)
    • Retrocompatibilità Legacy: supporto in lettura e scrittura (--legacy / --legacy-json) per [SECTION] ... [/SECTION], [FREETEXT] ... [/FREETEXT], [COMPOSITE_REQUIREMENT] e REFS:
    • Validatore Semantico (SDocValidator): verifica tipi di nodo, proprietà composite, campi obbligatori, ordine dei campi, opzioni SingleChoice/MultipleChoice/Tag, relazioni ammesse dalla grammatica e unicità degli UID.

Utilizzo da CLI

# Convertire JSON in SDOC (sintassi moderna StrictDoc)
python3 strictdock-parser.py test.json test.sdoc

# Convertire JSON in SDOC (sintassi legacy [SECTION] / [FREETEXT])
python3 strictdock-parser.py --legacy test.json test_legacy.sdoc

# Convertire SDOC in JSON (AST completo lossless)
python3 strictdock-parser.py test.sdoc output.json

# Convertire SDOC in JSON (schema compatto legacy con SECTIONS / REQUIREMENTS / FREETEXT)
python3 strictdock-parser.py --legacy-json test.sdoc output_legacy.json

# Validare un file .sdoc, .sgra o .json
python3 strictdock-parser.py --validate test.sdoc

# Migrare un file .sdoc legacy alla sintassi StrictDoc moderna
python3 strictdock-parser.py legacy_doc.sdoc modern_doc.sdoc

Utilizzo come Libreria Python

from strictdoc_parser import (
    json_to_sdoc,
    sdoc_to_json,
    parse_sdoc,
    write_sdoc,
    SDocValidator,
)

# Da JSON a SDOC
sdoc_text = json_to_sdoc(json_string, legacy=False, validate=True)

# Da SDOC a JSON
json_text = sdoc_to_json(sdoc_text, legacy_json=False, validate=True)

# Parsing in AST e validazione semantica
doc = parse_sdoc(sdoc_text)
SDocValidator.validate_document(doc)

Esempio (test.json $\to$ test.sdoc)

Input (test.json):

{
    "TITLE": "Test Documentation",
    "SECTIONS": [
        {
            "TITLE": "System Overview",
            "FREETEXT": "This documentation is used to test the script",
            "REQUIREMENTS": [
                {
                    "UID": "TEST-01",
                    "TITLE": "Test the script",
                    "STATEMENT": "This is a Test",
                    "RATIONALE": "This is a test"
                }
            ]
        }
    ]
}

Output Moderno (test.sdoc):

[DOCUMENT]
TITLE: Test Documentation

[[SECTION]]
TITLE: System Overview

[TEXT]
STATEMENT: >>>
This documentation is used to test the script
<<<

[REQUIREMENT]
UID: TEST-01
TITLE: Test the script
STATEMENT: >>>
This is a Test
<<<
RATIONALE: >>>
This is a test
<<<

[[/SECTION]]

Eseguire i Test

python3 -m unittest discover -s tests -v

Metadata

Release files for json-to-strictdoc 1.0.0

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

Source distribution (sdist)

Source distribution for json-to-strictdoc 1.0.0
File Size Uploaded Provenance Actions
json_to_strictdoc-1.0.0.tar.gz 36.0 kB Without provenance Details for json_to_strictdoc-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for json-to-strictdoc 1.0.0
File Interpreter ABI Platform Actions
json_to_strictdoc-1.0.0-py3-none-any.whl Python 3 none any Details for json_to_strictdoc-1.0.0-py3-none-any.whl

Total release size: 74.0 kB

Release files / json_to_strictdoc-1.0.0.tar.gz

Download URL json_to_strictdoc-1.0.0.tar.gz
Size 36.0 kB
Tags Source
SHA-256 checksum
How to use checksums
214df8ebf667da45303defb41a375afb8f2cdf49b58410a062fc6225b7c6e79e
BLAKE2b-256 checksum
How to use checksums
1f6f22dd97fa008f9af7f3252e3b8b12084a55c1b6c7ab7f6b49038267e83de8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.13

Release files / json_to_strictdoc-1.0.0-py3-none-any.whl

Download URL json_to_strictdoc-1.0.0-py3-none-any.whl
Size 38.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41f65a142b2798cf8842afb829a5ff2d2568363a2b25ae6c9aa4835824871874
BLAKE2b-256 checksum
How to use checksums
6c75abe2d59f47f3c71983c77a518ed8c4af275bae54b226c76b801142b03ff4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.13

Security for json-to-strictdoc 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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