Document
The main entry point of the Docraft library. DocraftDocument owns the
document tree (DOM), settings, metadata, and drives parsing, templating, and
rendering.
-
class DocraftDocument : public docraft::management::DocraftDOMFacade<DocraftDocument>
High-level document container that owns document configuration and the DOM node list.
DocraftDocument is the primary API surface for building a document tree, and invoking rendering. Configuration (metadata, settings, keywords) is delegated to DocraftDocumentConfig for single responsibility.
Public Functions
-
explicit DocraftDocument(const std::string &document_title = "Untitled Document")
Creates a document with an optional title.
- Parameters:
document_title – Human-readable title for the document metadata.
-
virtual ~DocraftDocument() = default
Virtual destructor.
Adds a node to the document DOM.
- Parameters:
node – Node to append to the document.
-
void configure_document_settings()
Applies document settings to the underlying rendering context.
-
void template_document()
Applies template processing to the document DOM using the configured template engine.
-
void render()
Renders the document using the configured context and renderer.
Sets a factory used to create backend providers.
Passing nullptr restores the default Haru providers factory.
Backward-compatible alias for set_capability_providers_factory.
-
std::vector<std::shared_ptr<const model::DocraftNode>> nodes() const
Returns the document DOM nodes.
- Returns:
Vector of root nodes.
-
std::vector<std::shared_ptr<model::DocraftNode>> &edit_nodes()
Traverses the document DOM and executes a callback on each node.
- Parameters:
callback – Function called for each node and operation (enter/exit).
-
management::DocraftDocumentConfig &edit_config()
Returns the document configuration manager.
- Returns:
Reference to the configuration container.
-
const management::DocraftDocumentConfig &config() const
-
std::shared_ptr<DocraftDocumentContext> edit_context()
Returns the document context used for rendering.
- Returns:
Shared pointer to the rendering context.
-
std::shared_ptr<const DocraftDocumentContext> context() const
-
void refresh_auto_keywords()
-
explicit DocraftDocument(const std::string &document_title = "Untitled Document")