Skip to content

Commit 0c674c1

Browse files
authored
Merge pull request #2261 from strictdoc-project/stanislaw/docs
[[NODE]] migration: print [SECTION] deprecation message
2 parents 3e0fbc7 + cae061f commit 0c674c1

File tree

9 files changed

+205
-62
lines changed

9 files changed

+205
-62
lines changed

docs/sphinx/source/strictdoc_01_user_guide.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ Which will resolve to the following document after inclusion:
12871287

12881288
The Composable Documents feature belongs to the list of features that may be less portable when it comes to interfacing with other tools. See :ref:`Portability considerations <UG_PORTABILITY_CONSIDERATIONS>`.
12891289

1290-
.. _UG_COMPOSITE_REQUIREMENT:
1290+
.. _UG_COMPOSITE_NODE:
12911291

12921292
Composite requirement
12931293
~~~~~~~~~~~~~~~~~~~~~
@@ -2971,7 +2971,7 @@ The portability of documentation, particularly when it involves requirements, sh
29712971
The following is a list of features that are considered less portable when it comes to interfacing with other tools through the existing export/import interfaces:
29722972

29732973
- :ref:`Composing documents from other documents <UG_COMPOSABLE_DOCUMENTS>`. Composing documents from other documents is a useful feature but it may not be directly supported by other tools. When exporting to JSON or ReqIF, StrictDoc by default does not export included documents but only the including documents.
2974-
- :ref:`Composite requirement <UG_COMPOSITE_REQUIREMENT>`. A Composite Requirement is a useful concept which is partially supported by StrictDoc but it may be supported less by other tools.
2974+
- :ref:`Composite requirement <UG_COMPOSITE_NODE>`. A Composite Requirement is a useful concept which is partially supported by StrictDoc but it may be supported less by other tools.
29752975
- :ref:`Section without a level <SECTION_WITHOUT_A_LEVEL>`. Table of contents hierarchy where some nodes do not have TOC levels (or have custom TOC levels) can cause problems when exporting/importing documentation content if an interfacing tool does not support custom TOC nodes.
29762976

29772977
.. note::

docs/strictdoc_01_user_guide.sdoc

Lines changed: 133 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ Example of a composite node:
570570

571571
[[/SECTION]]
572572

573-
The document elements are described below.
573+
The document elements are described further below, see [LINK: SECTION-UG-DOCUMENT-ELEMENTS].
574574
<<<
575575

576576
[[/SECTION]]
@@ -667,7 +667,8 @@ The Project Statistics screen provides metrics for counting the number of TBDs (
667667

668668
[[SECTION]]
669669
MID: b4ceeb12bdf1448cb97b7974d4980189
670-
TITLE: Grammar elements
670+
UID: SECTION-UG-DOCUMENT-ELEMENTS
671+
TITLE: Document elements
671672

672673
[[SECTION]]
673674
MID: db088d5977934056a851a24988e9266c
@@ -887,14 +888,18 @@ The additional metadata is also included on the front page of the exported PDF.
887888

888889
[[/SECTION]]
889890

891+
[[SECTION]]
892+
MID: 93085eee6a214a0a85aa94472f0a0a6c
893+
TITLE: Leaf nodes
894+
890895
[[SECTION]]
891896
MID: 23cbc84e92294aa0aeb0bb279d914480
892897
TITLE: Text
893898

894899
[TEXT]
895900
MID: 4474709783b74b1ca31fa754c712344e
896901
STATEMENT: >>>
897-
A text node is the most basic document node which is used for normal document text.
902+
A text node is the most basic document node which is used for normal document text. The ``[TEXT]`` is one of the default leaf elements declared in StrictDoc's default grammar. See [LINK: SECTION-UG-DOCUMENT-GRAMMAR].
898903

899904
.. code-block:: text
900905

@@ -922,7 +927,9 @@ TITLE: Requirement
922927
[TEXT]
923928
MID: f221cd0c72f846b385ec2f0a9ddd15d5
924929
STATEMENT: >>>
925-
The REQUIREMENT element is used for creating requirements, for example technical requirements or project requirements.
930+
The ``REQUIREMENT`` is used for creating requirements, for example technical requirements or project requirements.
931+
932+
Similar to ``TEXT``, the ``REQUIREMENT`` is a default leaf element declared in StrictDoc's default grammar. See [LINK: SECTION-UG-DOCUMENT-GRAMMAR].
926933

927934
.. code-block:: text
928935

@@ -968,7 +975,7 @@ The following ``REQUIREMENT`` fields are supported:
968975
Note: Multiple comment fields are possible.
969976

970977
* - ``RELATIONS``
971-
- List of requirement relations. Note: Before StrictDoc v0.0.45, this field was called ``REFS``.
978+
- List of requirement relations.
972979

973980
Currently, all ``[REQUIREMENT]``'s fields are optional but most of the time at
974981
least the ``STATEMENT`` field as well as the ``TITLE`` field should be
@@ -1052,7 +1059,7 @@ supported.
10521059
[[SECTION]]
10531060
MID: f10fd08172054423be7c00fcd16e61e9
10541061
UID: SDOC_UG_REQUIREMENT_RELATIONS
1055-
TITLE: Relations (previously REFS)
1062+
TITLE: Relations
10561063

10571064
[TEXT]
10581065
MID: c0c9c15d57e742ed80f12b8895f01de0
@@ -1248,6 +1255,59 @@ comments can be single-line or multiline.
12481255

12491256
[[/SECTION]]
12501257

1258+
[[/SECTION]]
1259+
1260+
[[SECTION]]
1261+
MID: a1ad4861e5bc442baf38383b29c901a1
1262+
UID: UG_COMPOSITE_NODE
1263+
TITLE: Composite nodes
1264+
1265+
[TEXT]
1266+
MID: ce69fe89236a4bcfa104a640def4b64a
1267+
STATEMENT: >>>
1268+
A composite node is similar to a regular leaf node, but it can also nest other nodes.
1269+
1270+
This element can be useful in lower-level specification documents where a given section must describe a single feature, and the description requires one or more levels of nesting. In such cases, it may be natural to use a composite node that is tightly connected to several related sub-nodes.
1271+
1272+
The ``[[SECTION]]`` element is a reserved composite node in StrictDoc's default grammar, used to represent nested document sections or chapters. Users can also define custom composite nodes by registering them in the document grammar as follows:
1273+
1274+
.. code-block:: text
1275+
1276+
[GRAMMAR]
1277+
ELEMENTS:
1278+
- TAG: COMPOSITE_REQUIREMENT
1279+
PROPERTIES:
1280+
IS_COMPOSITE: True
1281+
FIELDS:
1282+
- TITLE: MID
1283+
TYPE: String
1284+
REQUIRED: False
1285+
- TITLE: UID
1286+
TYPE: String
1287+
REQUIRED: False
1288+
- TITLE: STATEMENT
1289+
TYPE: String
1290+
REQUIRED: True
1291+
1292+
[[COMPOSITE_REQUIREMENT]]
1293+
STATEMENT: Statement
1294+
1295+
[REQUIREMENT]
1296+
STATEMENT: Substatement #1
1297+
1298+
[REQUIREMENT]
1299+
STATEMENT: Substatement #2
1300+
1301+
[REQUIREMENT]
1302+
STATEMENT: Substatement #3
1303+
1304+
[[/COMPOSITE_REQUIREMENT]]
1305+
1306+
.. note::
1307+
1308+
Composite requirements should not be used in every document. In most cases, a simple combination of nested ``[[SECTION]]`` and ``[[REQUIREMENT]]`` elements is sufficient. See also [LINK: UG_PORTABILITY_CONSIDERATIONS].
1309+
<<<
1310+
12511311
[[SECTION]]
12521312
MID: c8c15acf52a24c99922bdae6711f5120
12531313
UID: ELEMENT_SECTION
@@ -1364,6 +1424,50 @@ are set to ``LEVEL: None`` by StrictDoc automatically.
13641424

13651425
[[/SECTION]]
13661426

1427+
[[SECTION]]
1428+
MID: 0f52cfb294af480e806f0434d0a07757
1429+
TITLE: Section grammar definition
1430+
1431+
[TEXT]
1432+
MID: 7f2967ea1a41426ba15c0bdde2664920
1433+
STATEMENT: >>>
1434+
The ``[[SECTION]]`` element is registered by default in StrictDoc's grammar, but users can override this declaration by defining it manually in the grammar specification. See [LINK: SECTION-UG-DOCUMENT-GRAMMAR].
1435+
1436+
Default ``[[SECTION]]`` grammar is equivalent to the following manual definition:
1437+
1438+
.. code-block::
1439+
1440+
[GRAMMAR]
1441+
ELEMENTS:
1442+
- TAG: SECTION
1443+
PROPERTIES:
1444+
IS_COMPOSITE: True
1445+
PREFIX: None
1446+
VIEW_STYLE: Narrative
1447+
FIELDS:
1448+
- TITLE: MID
1449+
TYPE: String
1450+
REQUIRED: False
1451+
- TITLE: UID
1452+
TYPE: String
1453+
REQUIRED: False
1454+
- TITLE: LEVEL
1455+
TYPE: String
1456+
REQUIRED: True
1457+
- TITLE: PREFIX
1458+
TYPE: String
1459+
REQUIRED: True
1460+
- TITLE: TITLE
1461+
TYPE: String
1462+
REQUIRED: True
1463+
1464+
A user can add any custom field to the grammar declaration. However, the default set of fields typically covers most use cases.
1465+
<<<
1466+
1467+
[[/SECTION]]
1468+
1469+
[[/SECTION]]
1470+
13671471
[[/SECTION]]
13681472

13691473
[[SECTION]]
@@ -1450,53 +1554,6 @@ Which will resolve to the following document after inclusion:
14501554

14511555
[[/SECTION]]
14521556

1453-
[[SECTION]]
1454-
MID: a1ad4861e5bc442baf38383b29c901a1
1455-
UID: UG_COMPOSITE_REQUIREMENT
1456-
TITLE: Composite requirement
1457-
1458-
[TEXT]
1459-
MID: ce69fe89236a4bcfa104a640def4b64a
1460-
STATEMENT: >>>
1461-
.. note::
1462-
The composite requirements feature shows promise, but it has not yet attracted significant demand from both the core developers of StrictDoc and its users. While the use of composite requirements via the command line is implemented and supported, the web interface does not currently offer this support. Experience has shown that composite requirements can often be represented as a combination of sections and standard requirements. If there is a compelling use case for full support of composite requirements, please reach out to the developers.
1463-
1464-
A ``[COMPOSITE_REQUIREMENT]`` is a requirement that combines requirement
1465-
properties of a ``[REQUIREMENT]`` element and grouping features of a ``[SECTION]``
1466-
element. This element can be useful in lower-level specifications documents
1467-
where a given section of a document has to describe a single feature and the
1468-
description requires a one or more levels of nesting. In this case, it might be
1469-
natural to use a composite requirement that is tightly connected to a few
1470-
related sub-requirements.
1471-
1472-
.. code-block:: text
1473-
1474-
[COMPOSITE_REQUIREMENT]
1475-
STATEMENT: Statement
1476-
1477-
[REQUIREMENT]
1478-
STATEMENT: Substatement #1
1479-
1480-
[REQUIREMENT]
1481-
STATEMENT: Substatement #2
1482-
1483-
[REQUIREMENT]
1484-
STATEMENT: Substatement #3
1485-
1486-
[/COMPOSITE_REQUIREMENT]
1487-
1488-
Special feature of ``[COMPOSITE_REQUIREMENT]``: like ``[SECTION]`` element, the
1489-
``[COMPOSITE_REQUIREMENT]`` elements can be nested within each other. However,
1490-
``[COMPOSITE_REQUIREMENT]`` cannot nest sections.
1491-
1492-
.. note::
1493-
1494-
Composite requirements should not be used in every document.
1495-
Most often, a more basic combination of nested ``[SECTION]`` and ``[REQUIREMENT]`` elements should do the job.
1496-
<<<
1497-
1498-
[[/SECTION]]
1499-
15001557
[[/SECTION]]
15011558

15021559
[[SECTION]]
@@ -1529,6 +1586,27 @@ a grammar with four fields including a custom ``VERIFICATION`` field.
15291586

15301587
[GRAMMAR]
15311588
ELEMENTS:
1589+
- TAG: SECTION
1590+
PROPERTIES:
1591+
IS_COMPOSITE: True
1592+
PREFIX: None
1593+
VIEW_STYLE: Narrative
1594+
FIELDS:
1595+
- TITLE: MID
1596+
TYPE: String
1597+
REQUIRED: False
1598+
- TITLE: UID
1599+
TYPE: String
1600+
REQUIRED: False
1601+
- TITLE: LEVEL
1602+
TYPE: String
1603+
REQUIRED: True
1604+
- TITLE: PREFIX
1605+
TYPE: String
1606+
REQUIRED: True
1607+
- TITLE: TITLE
1608+
TYPE: String
1609+
REQUIRED: True
15321610
- TAG: TEXT
15331611
FIELDS:
15341612
- TITLE: UID
@@ -1613,9 +1691,6 @@ The supported field types are:
16131691
* - ``Tag``
16141692
- comma-separated list of tags/key words. Only Alphanumeric tags (a-z, A-Z, 0-9 and underscore) are supported.
16151693

1616-
* - ``Reference``
1617-
- **DEPRECATED:** comma-separated list with allowed reference types: ``ParentReqReference``, ``FileReference``. In the newer versions of StrictDoc (0.0.45+), a separate ``RELATIONS:`` section is used to configure the available relations.
1618-
16191694
.. note::
16201695

16211696
The **field type** also influences how the field is presented in the web editor UI. A ``SingleChoice`` field enables an auto-completion function, which is useful in cases where the same values are entered repeatedly (such as requirement owners, test case types, or status fields).
@@ -3314,7 +3389,7 @@ The portability of documentation, particularly when it involves requirements, sh
33143389
The following is a list of features that are considered less portable when it comes to interfacing with other tools through the existing export/import interfaces:
33153390

33163391
- [LINK: UG_COMPOSABLE_DOCUMENTS]. Composing documents from other documents is a useful feature but it may not be directly supported by other tools. When exporting to JSON or ReqIF, StrictDoc by default does not export included documents but only the including documents.
3317-
- [LINK: UG_COMPOSITE_REQUIREMENT]. A Composite Requirement is a useful concept which is partially supported by StrictDoc but it may be supported less by other tools.
3392+
- [LINK: UG_COMPOSITE_NODE]. A Composite Requirement is a useful concept which is natively supported by StrictDoc but it may be supported less by other tools.
33183393
- [LINK: SECTION_WITHOUT_A_LEVEL]. Table of contents hierarchy where some nodes do not have TOC levels (or have custom TOC levels) can cause problems when exporting/importing documentation content if an interfacing tool does not support custom TOC nodes.
33193394

33203395
.. note::
@@ -3884,7 +3959,7 @@ TITLE: Appendices
38843959
[[SECTION]]
38853960
MID: 2ed20461aeb4462b812432c08aa006be
38863961
UID: SECTION-UG-NODE-MIGRATION
3887-
TITLE: [[NODE]] migration
3962+
TITLE: [[NODE]] migration (2025 Q2-Q3)
38883963

38893964
[TEXT]
38903965
MID: 9d55b69bf789487e814210da06fc4164

strictdoc/backend/sdoc/reader.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
from strictdoc.backend.sdoc.models.constants import DOCUMENT_MODELS
1212
from strictdoc.backend.sdoc.models.document import SDocDocument
1313
from strictdoc.backend.sdoc.models.document_grammar import DocumentGrammar
14-
from strictdoc.backend.sdoc.models.node import SDocNode, SDocNodeField
14+
from strictdoc.backend.sdoc.models.node import (
15+
SDocCompositeNode,
16+
SDocNode,
17+
SDocNodeField,
18+
)
1519
from strictdoc.backend.sdoc.models.section import SDocSection
1620
from strictdoc.backend.sdoc.pickle_cache import PickleCache
1721
from strictdoc.backend.sdoc.processor import ParseContext, SDocParsingProcessor
@@ -201,6 +205,9 @@ def migrate_sections(sdoc):
201205
new_node = SDReader.convert(node_)
202206
sdoc.section_contents[node_idx_] = new_node
203207

208+
elif isinstance(node_, SDocCompositeNode):
209+
SDReader.migration_sections_grammar(sdoc)
210+
204211
@staticmethod
205212
def migration_sections_grammar(sdoc: SDocDocument):
206213
grammar: DocumentGrammar = assert_cast(sdoc.grammar, DocumentGrammar)

strictdoc/core/traceability_index_builder.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import glob
44
import os
55
import sys
6+
from time import sleep
67
from typing import Dict, Iterator, List, Optional, Set, Union
78

89
from textx import TextXSyntaxError
@@ -268,6 +269,8 @@ def create_from_document_tree(
268269
file_dependency_manager=file_dependency_manager,
269270
)
270271

272+
found_deprecated_section: bool = False
273+
271274
# It seems to be impossible to accomplish everything in just one for
272275
# loop. One particular problem that requires two passes: it is not
273276
# possible to know after one iteration which of the requirements
@@ -377,6 +380,29 @@ def create_from_document_tree(
377380
print_fragments=False,
378381
print_fragments_from_files=False,
379382
):
383+
if (
384+
isinstance(node, SDocSection)
385+
and not found_deprecated_section
386+
):
387+
found_deprecated_section = True
388+
389+
def print_line(text: str):
390+
print(f"\x1b[7;90m{text}\x1b[0m", flush=True) # noqa: T201
391+
392+
print_line(
393+
"WARNING: At least one document in this documentation tree "
394+
"uses a deprecated [SECTION] element. "
395+
"All [SECTION] elements must be renamed to [[SECTION]], "
396+
"and the SECTION element must be registered in the "
397+
"document grammar. "
398+
"See the migration guide for more details:\n"
399+
"https://strictdoc.readthedocs.io/en/latest/latest/docs/strictdoc_01_user_guide.html#SECTION-UG-NODE-MIGRATION\n"
400+
"This warning will become an error in 2025 Q3. "
401+
"Sleeping for 5 seconds..."
402+
)
403+
404+
sleep(5)
405+
380406
if isinstance(node, SDocNode):
381407
try:
382408
SDocValidator.validate_node(

tests/end2end/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Dummy comment to trigger CI
1+
# Dummy comment to trigger CI.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[DOCUMENT]
2+
TITLE: Hello world doc
3+
4+
[SECTION]
5+
TITLE: Foo
6+
7+
[/SECTION]
8+
9+
[SECTION]
10+
UID: BAR-UID
11+
LEVEL: None
12+
TITLE: Bar
13+
REQ_PREFIX: BAR-
14+
15+
[/SECTION]

0 commit comments

Comments
 (0)