You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An SDoc document consists of a ``[DOCUMENT]`` declaration followed by a sequence of nodes:
548
+
An SDoc document consists of a ``[DOCUMENT]`` declaration followed by a sequence of **leaf nodes** or **composite nodes**.
548
549
549
-
- Lead nodes: ``[TEXT]`` or ``[REQUIREMENT]``
550
-
- Composite nodes: ``[COMPOSITE_REQUIREMENT]``
551
-
- Section nodes that group other nodes recursively: ``[SECTION]``.
550
+
A **leaf node** cannot contain any child nodes. It is simply a node with text fields. The default leaf nodes are defined as ``[TEXT]`` or ``[REQUIREMENT]``. Any other ``[...]`` custom leaf node can be registered by a user in a document grammar.
552
551
553
-
Each construct is described in more detail below.
552
+
Example of a lead node:
553
+
554
+
.. code-block:: text
555
+
556
+
[REQUIREMENT]
557
+
STATEMENT: StrictDoc shall be based on a document model.
558
+
559
+
A **composite node** can contain other composite or leaf nodes. The default composite node is ``[[SECTION]]`` which models a section/chapter in a document. Any other ``[[...]]`` composite node can be registered by a user in a document grammar.
560
+
561
+
Example of a composite node:
562
+
563
+
.. code-block:: text
564
+
565
+
[[SECTION]]
566
+
TITLE: Document model
567
+
568
+
[REQUIREMENT]
569
+
STATEMENT: StrictDoc shall be based on a document model.
570
+
571
+
[[/SECTION]]
572
+
573
+
The document elements are described below.
554
574
<<<
555
575
576
+
[[/SECTION]]
577
+
578
+
[[SECTION]]
579
+
MID: ec9dcd4ad28a4852bc47723e667006df
580
+
TITLE: Syntax rules
581
+
556
582
[[SECTION]]
557
583
MID: 926894ac8efc4e99943741691b3d4efe
558
584
UID: SECTION-UG-Strict-rule-1
@@ -561,7 +587,7 @@ TITLE: Strict rule #1: One empty line between all nodes
561
587
[TEXT]
562
588
MID: 2ebd1f2d3c8746a383d71232756c3bd3
563
589
STATEMENT: >>>
564
-
StrictDoc's grammar requires each node, such as ``[REQUIREMENT]``, ``[SECTION]``,
590
+
StrictDoc's grammar requires each node, such as ``[REQUIREMENT]``, ``[[SECTION]]``,
565
591
etc., to be separated with exactly one empty line from the nodes surrounding it.
566
592
This rule is valid for all nodes. Absence of an empty line or presence of more
567
593
than one empty line between two nodes will result in an SDoc parsing error.
@@ -577,11 +603,13 @@ TITLE: Strict rule #2: No content is allowed outside of SDoc grammar
577
603
[TEXT]
578
604
MID: 686eb01cf7db44c4bd1edd72ccb02ed0
579
605
STATEMENT: >>>
580
-
StrictDoc's grammar does not allow any content to be written outside of the SDoc
581
-
grammatical constructs. It is assumed that the critical content shall always be
582
-
written in form of requirements:
583
-
``[REQUIREMENT]`` and ``[COMPOSITE_REQUIREMENT]``. Non-critical content shall
584
-
be specified using ``[TEXT]`` nodes.
606
+
StrictDoc's grammar does not allow any content to be written outside the SDoc grammatical constructs.
607
+
608
+
It is assumed that the critical content shall always be
609
+
written in form of leaf nodes and composite nodes, such as
610
+
``[REQUIREMENT]`` and ``[[SECTION]]``.
611
+
612
+
Non-critical content shall be specified using the ``[TEXT]`` leaf nodes.
585
613
<<<
586
614
587
615
[[/SECTION]]
@@ -1228,7 +1256,11 @@ TITLE: Section
1228
1256
[TEXT]
1229
1257
MID: 14e5fea31b1c41bf8c743f18e51053e0
1230
1258
STATEMENT: >>>
1231
-
The ``[SECTION]`` element is used for creating document chapters and grouping
1259
+
.. warning::
1260
+
1261
+
As of 2025 Q2, StrictDoc is switching to a new ``[[SECTION]]`` syntax for declaring sections (previously ``[SECTION]``). If you are an existing user, please follow the migration guide [LINK: SECTION-UG-NODE-MIGRATION].
1262
+
1263
+
The ``[[SECTION]]`` element can used for creating document chapters and grouping
1232
1264
requirements into logical groups. It is equivalent to the use of ``#``, ``##``,
1233
1265
``###``, etc., in Markdown and ``====``, ``----``, ``~~~~`` in RST.
1234
1266
@@ -3849,6 +3881,91 @@ The existing workaround for this problem is to increase a number of semaphores i
3849
3881
MID: b55c23b113d54802b5717f7a82a45bd2
3850
3882
TITLE: Appendices
3851
3883
3884
+
[[SECTION]]
3885
+
MID: 2ed20461aeb4462b812432c08aa006be
3886
+
UID: SECTION-UG-NODE-MIGRATION
3887
+
TITLE: [[NODE]] migration
3888
+
3889
+
[TEXT]
3890
+
MID: 9d55b69bf789487e814210da06fc4164
3891
+
STATEMENT: >>>
3892
+
As of 2025 Q2, the following changes are made to StrictDoc's grammar in a partially backward-incompatible manner. The relevant GitHub issue related to the migration:
3893
+
3894
+
`Migration: SDoc model: Merge Section, Node, Composite Node into just Node #2193 <https://github.com/strictdoc-project/strictdoc/issues/2193>`_
3895
+
3896
+
1\) The ``[[CUSTOM_NODE]]`` syntax with two square brackets around the element name has been introduced for composite nodes.
3897
+
3898
+
Example of declaring a composite node in a grammar and using it in a document:
3899
+
3900
+
.. code-block::
3901
+
3902
+
[GRAMMAR]
3903
+
ELEMENTS:
3904
+
- TAG: SECTION
3905
+
PROPERTIES:
3906
+
IS_COMPOSITE: True
3907
+
PREFIX: None
3908
+
VIEW_STYLE: Narrative
3909
+
FIELDS:
3910
+
- TITLE: MID
3911
+
TYPE: String
3912
+
REQUIRED: False
3913
+
- TITLE: UID
3914
+
TYPE: String
3915
+
REQUIRED: False
3916
+
- TITLE: TITLE
3917
+
TYPE: String
3918
+
REQUIRED: True
3919
+
3920
+
[[SECTION]]
3921
+
TITLE: Section #1
3922
+
3923
+
[[/SECTION]]
3924
+
3925
+
Using the new syntax, it is now possible to declare any custom composite element, such as what ``[COMPOSITE_REQUIREMENT]`` used to provide before.
3926
+
3927
+
2\) The previously used ``[SECTION]`` syntax with one square bracket around the SECTION is now DEPRECATED, but the old behavior is still supported. The users are encouraged to migrate all ``[SECTION]`` elements to the new ``[[SECTION]]`` syntax. To support the new behavior, the grammar must include a declaration for a composite SECTION element similar to the example provided above.
3928
+
3929
+
3\) The ``[COMPOSITE_REQUIREMENT]`` node has been removed from the codebase. This is a backward-incompatible change, but it is assumed that no users should be affected since this feature has never been developed enough to be useful.
3930
+
<<<
3931
+
3932
+
[[SECTION]]
3933
+
MID: 6f15ef6876ba48598d5560aaf4664ec9
3934
+
TITLE: How to migrate from [SECTION] to [[SECTION]]
3935
+
3936
+
[TEXT]
3937
+
MID: 19fe5099aa034eddb960cc88953ace0e
3938
+
STATEMENT: >>>
3939
+
The migration from ``[SECTION]`` to the new composite ``[[SECTION]]`` syntax is mostly straightforward and can be done manually. However, StrictDoc also provides a dedicated configuration option to assist with this migration.
3940
+
3941
+
1\) **Manual approach**
3942
+
3943
+
Update all instances of ``[SECTION]`` to ``[[SECTION]]`` manually, or use a combination of ``find`` and ``sed``. Additionally, make sure to update all document grammar declarations to include the new composite ``[[SECTION]]`` element.
3944
+
3945
+
2\) **Semi-automated approach (experimental)**
3946
+
3947
+
StrictDoc can automatically migrate SDoc files if the project configuration option ``section_behavior`` is set as follows:
3948
+
3949
+
.. code-block::
3950
+
3951
+
[project]
3952
+
section_behavior = "[[SECTION]]"
3953
+
3954
+
With this option enabled, StrictDoc's ``export`` command will convert all ``[SECTION]`` nodes to ``[[SECTION]]`` when writing SDoc files.
3955
+
3956
+
To perform the migration, run the export command:
3957
+
3958
+
.. code-block::
3959
+
3960
+
strictdoc export . --formats=sdoc
3961
+
3962
+
The resulting files will have all ``[SECTION]`` nodes replaced with ``[[SECTION]]``.
0 commit comments