Doctools
Provides tools to assist with generating documentation for SSVC decision points.
Writes the following files for each decision point: - a json example that can be used in the decision point documentation
Examples
To generate the documentation for the decision points, use the following command:
python -m ssvc.doctools --overwrite --datadir ./tmp/json_out`
To regenerate the existing docs, use the following command:
python -m ssvc.doctools --overwrite --datadir data
EnsureDirExists
A runtime context that ensures that a directory exists or creates it otherwise.
Example:
with EnsureDirExists(dir):
assert os.path.exists(dir)
Source code in src/ssvc/doctools.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
__init__(dir)
Create a new EnsureDirExists context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
str
|
The directory to ensure exists. |
required |
Returns:
Name | Type | Description |
---|---|---|
EnsureDirExists |
The new EnsureDirExists context. |
Source code in src/ssvc/doctools.py
101 102 103 104 105 106 107 108 109 110 111 |
|
dump_decision_point(jsondir, dp, overwrite)
Generate the markdown table, json example, and markdown table file for a decision point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
jsondir
|
str
|
The directory to write the json example to. |
required |
outdir
|
str
|
The directory to write the markdown table file to. |
required |
dp
|
SsvcDecisionPoint
|
The decision point to generate documentation for. |
required |
overwrite
|
bool
|
Whether to overwrite existing files. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
None
|
A dictionary with the following keys: - include_file: The path to the markdown table file. - symlink: The path to the symlink that points to the markdown table file. - json_file: The path to the json example file. |
Source code in src/ssvc/doctools.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
dump_json(basename, dp, jsondir, overwrite)
Generate the json example for a decision point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
basename
|
str
|
The basename of the json example file. |
required |
dp
|
SsvcDecisionPoint
|
The decision point to generate documentation for. |
required |
jsondir
|
str
|
The directory to write the json example to. |
required |
overwrite
|
bool
|
Whether to overwrite existing files. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The path to the json example file. |
Source code in src/ssvc/doctools.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
find_modules_to_import(directory='../decision_points', package='ssvc.decision_points')
Find all modules that contain decision points and import them.
This is necessary to ensure that all decision points are registered.
Source code in src/ssvc/doctools.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
main()
Generate the json examples for decision points and decision tables.
Emits the following files:
- json examples for each decision point in datadir/json/decision_points/
Source code in src/ssvc/doctools.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|