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.

void add_node(const std::shared_ptr<model::DocraftNode> &node)

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.

void set_capability_providers_factory(const std::shared_ptr<backend::IDocraftCapabilityProvidersFactory> &capability_providers_factory)

Sets a factory used to create backend providers.

Passing nullptr restores the default Haru providers factory.

void set_backend_providers_factory(const std::shared_ptr<backend::IDocraftBackendProvidersFactory> &backend_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()
void traverse_dom(const std::function<void(const std::shared_ptr<model::DocraftNode>&, DocraftDomTraverseOp)> &callback) const

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()