Generate an include file. directory - subdirectory to put file in (absolute or relative pathname) basename - base name of the file validity - ValidityCollection of valid usage statements to write threadsafety - ValidityCollection of thread safety statements to write
(self, directory, basename,
validity: ValidityCollection,
threadsafety : ValidityCollection,
commandpropertiesentry=None,
conditionalrendering = None,
successcodes=None,
errorcodes=None,
structextends=[]
)
| 249 | return f"ename:{name}" |
| 250 | |
| 251 | def writeInclude(self, directory, basename, |
| 252 | validity: ValidityCollection, |
| 253 | threadsafety : ValidityCollection, |
| 254 | commandpropertiesentry=None, |
| 255 | conditionalrendering = None, |
| 256 | successcodes=None, |
| 257 | errorcodes=None, |
| 258 | structextends=[] |
| 259 | ): |
| 260 | """Generate an include file. |
| 261 | |
| 262 | directory - subdirectory to put file in (absolute or relative pathname) |
| 263 | basename - base name of the file |
| 264 | validity - ValidityCollection of valid usage statements to write |
| 265 | threadsafety - ValidityCollection of thread safety statements to write |
| 266 | commandpropertiesentry - Command properties table or None |
| 267 | conditionalrendering - Whether command is affected by conditional rendering or None |
| 268 | successcodes - List of success codes (joined) or None |
| 269 | errorcodes - List of error codes (joined) or None |
| 270 | structextends - List of extended structures (not joined, may be []) |
| 271 | """ |
| 272 | # Create subdirectory, if needed |
| 273 | directory = Path(directory) |
| 274 | if not directory.is_absolute(): |
| 275 | directory = Path(self.genOpts.directory) / directory |
| 276 | self.makeDir(str(directory)) |
| 277 | |
| 278 | # Create validity file |
| 279 | filename = str(directory / f'{basename}{self.file_suffix}') |
| 280 | self.logMsg('diag', '# Generating include file:', filename) |
| 281 | |
| 282 | with open(filename, 'w', encoding='utf-8') as fp: |
| 283 | write(self.conventions.warning_comment, file=fp) |
| 284 | |
| 285 | # Valid Usage |
| 286 | if validity: |
| 287 | write('.Valid Usage (Implicit)', file=fp) |
| 288 | write('****', file=fp) |
| 289 | write(validity, file=fp, end='') |
| 290 | write('****', file=fp) |
| 291 | write('', file=fp) |
| 292 | |
| 293 | # Host Synchronization |
| 294 | if threadsafety: |
| 295 | # The heading of this block differs between projects, so an Asciidoc attribute is used. |
| 296 | write('.{externsynctitle}', file=fp) |
| 297 | write('****', file=fp) |
| 298 | write(threadsafety, file=fp, end='') |
| 299 | write('****', file=fp) |
| 300 | write('', file=fp) |
| 301 | |
| 302 | # Command Properties - contained within a block, to avoid table numbering |
| 303 | if commandpropertiesentry: |
| 304 | write('.Command Properties', file=fp) |
| 305 | write('****', file=fp) |
| 306 | write('[options="header", width="100%"]', file=fp) |
| 307 | write('|====', file=fp) |
| 308 | write(self.makeCommandPropertiesTableHeader(), file=fp) |