dita_writer Module
- class dita_sop_converter.dita_writer.DitaWriter(output_dir)
Bases:
objectWrite DITA topics, maps, and media assets from in-memory models.
Responsibilities
Normalize topic IDs into file-safe, DITA-safe identifiers.
Serialize
TopicModelobjects to.ditafiles.Serialize
MapModelto a DITA map (.ditamap).Persist image media referenced by
ImageBlockinstances.
This class is intentionally conservative: failures in image conversion should not prevent topic/map generation. Media problems are logged and fall back to pass-through behavior where possible.
Layout / step table semantics
TableBlock.kind == "layout-2col"in non-task topics is treated as a layout table that unwraps into sections/paragraphs.layout-2coltables in TASK topics are further inspected for Step/Action headers. When detected, they are converted into<steps>/<step>/<cmd>/<info>structures and the original table is omitted from the DITA output.
- write_map(map_model)
Serialize a
MapModelas a DITA map.ditamapfile.The method normalizes the map ID, verifies referenced topics exist, and writes a standard DITA map DOCTYPE declaration.
- Return type:
None- Parameters:
map_model (MapModel)
Parameters
- map_model :
Populated
MapModelwith entries.
- write_topics(topics)
Serialize all topics into
topics/*.ditaand return map entries.- Return type:
typing.List[dita_sop_converter.model.MapEntry]- Parameters:
topics (List[TopicModel])
Parameters
- topics :
List of fully populated
TopicModelinstances.
Returns
- list[MapEntry]
Map entries pointing at the topic files, in the same order.
- Parameters:
output_dir (str)