Skip to content

Commit 56e4d8e

Browse files
authored
Merge pull request #2244 from strictdoc-project/stanislaw/merge_nodes
backend/sdoc: document_grammar: make TEXT node to have Plain style by default
2 parents a43e47f + 9f04865 commit 56e4d8e

File tree

11 files changed

+495
-401
lines changed

11 files changed

+495
-401
lines changed

docs/strictdoc_01_user_guide.sdoc

Lines changed: 299 additions & 283 deletions
Large diffs are not rendered by default.

docs/strictdoc_02_feature_map.sdoc

Lines changed: 96 additions & 82 deletions
Large diffs are not rendered by default.

docs/strictdoc_03_faq.sdoc

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,23 @@ OPTIONS:
1111

1212
[GRAMMAR]
1313
ELEMENTS:
14+
- TAG: SECTION
15+
PROPERTIES:
16+
IS_COMPOSITE: True
17+
VIEW_STYLE: Narrative
18+
FIELDS:
19+
- TITLE: MID
20+
TYPE: String
21+
REQUIRED: False
22+
- TITLE: UID
23+
TYPE: String
24+
REQUIRED: False
25+
- TITLE: TITLE
26+
TYPE: String
27+
REQUIRED: True
1428
- TAG: TEXT
29+
PROPERTIES:
30+
VIEW_STYLE: Narrative
1531
FIELDS:
1632
- TITLE: MID
1733
TYPE: String
@@ -31,7 +47,7 @@ This document is a list of questions that people ask about StrictDoc.
3147
Missing a question or an answer? Ask it here: [LINK: SDOC_UG_CONTACT].
3248
<<<
3349

34-
[SECTION]
50+
[[SECTION]]
3551
MID: e972c79015524961863e095280a81aab
3652
TITLE: What is StrictDoc?
3753

@@ -45,9 +61,9 @@ StrictDoc is a spare-time open-source project developed by Stanislav Pankevich (
4561
The project exists since mid-2019.
4662
<<<
4763

48-
[/SECTION]
64+
[[/SECTION]]
4965

50-
[SECTION]
66+
[[SECTION]]
5167
MID: 86827c92ec3a493d8a2382b75b5277a8
5268
TITLE: Resources about StrictDoc
5369

@@ -71,9 +87,9 @@ Screencasts/tutorials:
7187
by Lukasz Juranek.
7288
<<<
7389

74-
[/SECTION]
90+
[[/SECTION]]
7591

76-
[SECTION]
92+
[[SECTION]]
7793
MID: 74235945ec4a4116aecbc883ffba54b7
7894
TITLE: Which web server is recommended for StrictDoc documentation?
7995

@@ -91,9 +107,9 @@ A very good alternative to GitHub pages is `Read the Docs <https://readthedocs.o
91107
If the project is private, you could use any server that reads HTML files from a folder. For example, Python has an embedded Web Server, see `this for example <https://pythonbasics.org/webserver>`_. Also you could try any web server based on Node.JS.
92108
<<<
93109

94-
[/SECTION]
110+
[[/SECTION]]
95111

96-
[SECTION]
112+
[[SECTION]]
97113
MID: 2e911dedb13348bf827f078bbbca44f4
98114
TITLE: Is StrictDoc compatible with Sphinx?
99115

@@ -114,9 +130,9 @@ There are users of StrictDoc who use both StrictDoc and Sphinx. The following wo
114130
There is a GitHub issue `Unexpected restriction on specific RST directives / compatibility with Breathe Sphinx Plugin #1093 <https://github.com/strictdoc-project/strictdoc/issues/1093>`_ where a closer bridging between StrictDoc and Sphinx was discussed with no specific and actionable outcome. This comment is `especially relevant <https://github.com/strictdoc-project/strictdoc/issues/1093#issuecomment-1505108384>`_ as well as the one about `possible implementation <https://github.com/strictdoc-project/strictdoc/issues/1093#issuecomment-1545599711>`_.
115131
<<<
116132

117-
[/SECTION]
133+
[[/SECTION]]
118134

119-
[SECTION]
135+
[[SECTION]]
120136
MID: 235122d2c10748918c7c6ff736e39d18
121137
UID: SECTION-FAQ-How-did-the-SDoc-text-language-become-what-it-is
122138
TITLE: How did the SDoc text language become what it is?
@@ -127,9 +143,9 @@ STATEMENT: >>>
127143
See [LINK: SECTION-FM-SDoc-text-markup] for a description of the SDoc feature.
128144
<<<
129145

130-
[/SECTION]
146+
[[/SECTION]]
131147

132-
[SECTION]
148+
[[SECTION]]
133149
MID: 1d4220cc9a5444a5bdbaee91c8c50670
134150
TITLE: How StrictDoc compares to other tools?
135151

@@ -139,7 +155,7 @@ STATEMENT: >>>
139155
This section offers a comparison of several requirements tools similar to StrictDoc.
140156
<<<
141157

142-
[SECTION]
158+
[[SECTION]]
143159
MID: a4533ae81bfe446295242add9156198e
144160
TITLE: Doorstop
145161

@@ -195,9 +211,9 @@ The roadmap of StrictDoc contains a work item for supporting the export/import
195211
to/from Doorstop format.
196212
<<<
197213

198-
[/SECTION]
214+
[[/SECTION]]
199215

200-
[SECTION]
216+
[[SECTION]]
201217
MID: 5012af516d18447caa3a2dbce97d3e4a
202218
TITLE: Sphinx
203219

@@ -223,9 +239,9 @@ The
223239
`StrictDoc <https://strictdoc.readthedocs.io/_/downloads/en/latest/pdf/>`_.
224240
<<<
225241

226-
[/SECTION]
242+
[[/SECTION]]
227243

228-
[SECTION]
244+
[[SECTION]]
229245
MID: 515bcae39d1f48eda0b72562871ab15a
230246
TITLE: Sphinx-Needs
231247

@@ -286,9 +302,9 @@ The difference between Sphinx-Needs and StrictDoc:
286302
<https://sphinxcontrib-needs.readthedocs.io/en/latest/index.html>`_.
287303
<<<
288304

289-
[/SECTION]
305+
[[/SECTION]]
290306

291-
[SECTION]
307+
[[SECTION]]
292308
MID: 4a77366154d74cf7ab34044bed1cd542
293309
TITLE: FRET
294310

@@ -311,9 +327,9 @@ FRET has an impressive list of
311327
FRET's user interface is built with Electron.
312328
<<<
313329

314-
[/SECTION]
330+
[[/SECTION]]
315331

316-
[SECTION]
332+
[[SECTION]]
317333
MID: 723731c256fc43dfb315a300f6429945
318334
TITLE: Other tools
319335

@@ -323,11 +339,11 @@ STATEMENT: >>>
323339
See also this GitHub gist for an overview of more tools available on GitHub: https://gist.github.com/stanislaw/aa40eb7de9f522ad482e5d239c435ff8.
324340
<<<
325341

326-
[/SECTION]
342+
[[/SECTION]]
327343

328-
[/SECTION]
344+
[[/SECTION]]
329345

330-
[SECTION]
346+
[[SECTION]]
331347
MID: ff143a18e98144bd86e10e29616c187b
332348
TITLE: How long has the StrictDoc project been around?
333349

@@ -366,9 +382,9 @@ The FastAPI/Turbo/Stimulus-based Web interface prototype was created to compleme
366382
See also: [LINK: SECTION-DP-Project-milestones].
367383
<<<
368384

369-
[/SECTION]
385+
[[/SECTION]]
370386

371-
[SECTION]
387+
[[SECTION]]
372388
MID: 6e5ed6bb36634220a0c583d21c96295f
373389
TITLE: Which StrictDoc statistics are available?
374390

@@ -383,4 +399,4 @@ The `pip trends <https://piptrends.com>`_ helps to visualize the Pip package dow
383399
`strictdoc vs reqif <https://piptrends.com/compare/strictdoc-vs-reqif>`_.
384400
<<<
385401

386-
[/SECTION]
402+
[[/SECTION]]

docs/strictdoc_20_L1_Open_Requirements_Tool.sdoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ ELEMENTS:
1919
TYPE: String
2020
REQUIRED: False
2121
- TAG: REQUIREMENT
22+
PROPERTIES:
23+
VIEW_STYLE: Table
2224
FIELDS:
2325
- TITLE: MID
2426
TYPE: String

docs/strictdoc_21_L2_StrictDoc_Requirements.sdoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ OPTIONS:
99

1010
[GRAMMAR]
1111
ELEMENTS:
12+
- TAG: SECTION
13+
PROPERTIES:
14+
IS_COMPOSITE: True
15+
VIEW_STYLE: Narrative
16+
FIELDS:
17+
- TITLE: MID
18+
TYPE: String
19+
REQUIRED: False
20+
- TITLE: UID
21+
TYPE: String
22+
REQUIRED: False
23+
- TITLE: TITLE
24+
TYPE: String
25+
REQUIRED: True
1226
- TAG: TEXT
1327
FIELDS:
1428
- TITLE: UID
@@ -18,6 +32,8 @@ ELEMENTS:
1832
TYPE: String
1933
REQUIRED: False
2034
- TAG: REQUIREMENT
35+
PROPERTIES:
36+
VIEW_STYLE: Table
2137
FIELDS:
2238
- TITLE: MID
2339
TYPE: String

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ dependencies = [
8888
"WebSockets",
8989

9090
# HTML2PDF dependencies
91-
"html2pdf4doc >= 0.0.17",
91+
"html2pdf4doc >= 0.0.18",
9292
]
9393
# @sdoc[/SDOC-SRS-89]
9494

strictdoc/backend/sdoc/models/document_grammar.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def __init__(
5555
"Zebra",
5656
)
5757
self.property_view_style: Optional[str] = (
58+
property_view_style if property_view_style != "" else None
59+
)
60+
self.property_view_style_lower: Optional[str] = (
5861
property_view_style.lower() if property_view_style != "" else None
5962
)
6063

@@ -187,7 +190,15 @@ def get_multiline_field_index(self) -> int:
187190
return self.multiline_field_index
188191

189192
def get_view_style(self) -> Optional[str]:
190-
return self.property_view_style
193+
if self.property_view_style_lower is not None:
194+
return self.property_view_style_lower
195+
# For backward compatibility with older versions that didn't have the
196+
# [[NODE]] syntax and didn't enter the corresponding template migration,
197+
# keep the TEXT nodes to have a "plain" style unless their type is
198+
# specified by the grammar.
199+
if self.tag == "TEXT":
200+
return "plain"
201+
return None
191202

192203
def get_relation_types(self) -> List[str]:
193204
return list(

strictdoc/backend/sdoc/writer.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,23 @@ def write_with_fragments(
234234
output += element.tag
235235
output += "\n"
236236

237-
if element.property_is_composite is not None:
237+
if (
238+
element.property_is_composite is not None
239+
or element.property_view_style is not None
240+
):
238241
output += " PROPERTIES:\n"
239-
output += " IS_COMPOSITE: "
240-
output += (
241-
"True" if element.property_is_composite else "False"
242-
)
243-
output += "\n"
242+
if element.property_is_composite is not None:
243+
output += " IS_COMPOSITE: "
244+
output += (
245+
"True"
246+
if element.property_is_composite
247+
else "False"
248+
)
249+
output += "\n"
250+
if element.property_view_style is not None:
251+
output += " VIEW_STYLE: "
252+
output += element.property_view_style
253+
output += "\n"
244254

245255
output += " FIELDS:\n"
246256
for grammar_field in element.fields:

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.

tests/end2end/screens/document/create_requirement/_SingleChoice/create_requirement_SingleChoice_field_using_autocomplete/input/document.sdoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ TITLE: Document 1
33

44
[GRAMMAR]
55
ELEMENTS:
6+
- TAG: TEXT
7+
FIELDS:
8+
- TITLE: UID
9+
TYPE: String
10+
REQUIRED: False
11+
- TITLE: STATEMENT
12+
TYPE: String
13+
REQUIRED: True
614
- TAG: REQUIREMENT
715
FIELDS:
816
- TITLE: UID

0 commit comments

Comments
 (0)