File tree Expand file tree Collapse file tree 7 files changed +74
-0
lines changed
tests/integration/features/plugin/01_traceability_index_build_finished Expand file tree Collapse file tree 7 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ from typing import TYPE_CHECKING
2+
3+ if TYPE_CHECKING :
4+ from strictdoc .core .traceability_index import TraceabilityIndex
5+
6+
7+ class StrictDocPlugin :
8+ def traceability_index_build_finished (
9+ self , traceability_index : "TraceabilityIndex"
10+ ) -> None :
11+ pass
Original file line number Diff line number Diff line change 2121 ServerCommandConfig ,
2222)
2323from strictdoc .core .environment import SDocRuntimeEnvironment
24+ from strictdoc .core .plugin import StrictDocPlugin
2425from strictdoc .helpers .auto_described import auto_described
2526from strictdoc .helpers .exception import StrictDocException
2627from strictdoc .helpers .file_modification_time import get_file_modification_time
@@ -134,6 +135,7 @@ def __init__(
134135 str
135136 ] = ProjectConfigDefault .DEFAULT_SECTION_BEHAVIOR ,
136137 statistics_generator : Optional [str ] = None ,
138+ user_plugin : Optional [StrictDocPlugin ] = None ,
137139 # Reserved for StrictDoc's internal use.
138140 _config_last_update : Optional [datetime .datetime ] = None ,
139141 ) -> None :
@@ -248,6 +250,7 @@ def __init__(
248250 self .section_behavior : Optional [str ] = section_behavior
249251
250252 self .statistics_generator : Optional [str ] = statistics_generator
253+ self .user_plugin : Optional [StrictDocPlugin ] = user_plugin
251254
252255 self .config_last_update : Optional [datetime .datetime ] = (
253256 _config_last_update
Original file line number Diff line number Diff line change @@ -222,6 +222,11 @@ def create(
222222 traceability_index .strictdoc_last_update
223223 )
224224
225+ if project_config .user_plugin is not None :
226+ project_config .user_plugin .traceability_index_build_finished (
227+ traceability_index
228+ )
229+
225230 return traceability_index
226231
227232 @staticmethod
Original file line number Diff line number Diff line change 1+ [DOCUMENT]
2+ TITLE: Hello world doc
3+
4+ [REQUIREMENT]
5+ TITLE: I am a title with a dot at the end, I will trigger the validation.
6+ STATEMENT: >>>
7+ System A shall do B.
8+ <<<
Original file line number Diff line number Diff line change 1+ import os
2+ import sys
3+
4+ from strictdoc .core .project_config import ProjectConfig
5+
6+ sys .path .append (os .path .dirname (__file__ ))
7+
8+ from user_plugin import UserPlugin
9+
10+
11+ def create_config () -> ProjectConfig :
12+ config = ProjectConfig (
13+ project_title = "StrictDoc Documentation" ,
14+ user_plugin = UserPlugin ()
15+ )
16+ return config
Original file line number Diff line number Diff line change 1+ RUN: %strictdoc export %S --output-dir %T | filecheck %s --dump-input=fail
2+ CHECK: warning: traceability_index_build_finished() is called.
3+ CHECK: warning: Node title ends with a dot: "I am a title with a dot at the end, I will trigger the validation.".
4+ CHECK: Published: Hello world doc
5+
6+ RUN: %cat %T/html/index.html | filecheck %s --dump-input=fail --check-prefix CHECK-HTML
7+ CHECK-HTML: Hello world doc
8+ CHECK-HTML: input.sdoc
Original file line number Diff line number Diff line change 1+ from strictdoc .backend .sdoc .models .node import SDocNode
2+ from strictdoc .core .document_iterator import DocumentCachingIterator
3+ from strictdoc .core .plugin import StrictDocPlugin
4+ from strictdoc .core .traceability_index import TraceabilityIndex
5+
6+
7+ class UserPlugin (StrictDocPlugin ):
8+ def traceability_index_build_finished (self , traceability : TraceabilityIndex ):
9+ print ("warning: traceability_index_build_finished() is called." ) # noqa: T201
10+
11+ for document in traceability .document_tree .document_list :
12+ assert document .meta is not None
13+
14+ document_iterator = DocumentCachingIterator (document )
15+
16+ for node , _ in document_iterator .all_content (
17+ print_fragments = False ,
18+ ):
19+ if not isinstance (node , SDocNode ):
20+ continue
21+
22+ if node .reserved_title .endswith ("." ):
23+ print (f'warning: Node title ends with a dot: "{ node .reserved_title } ".' ) # noqa: T201
You can’t perform that action at this time.
0 commit comments