Configuration❖
Overview❖
DocLang provides several configuration variables that control how commands are detected, parsed and interpreted. This page describes each option and explains the syntax rules that depend on them.
All configuration variables are optional. If not specified, DocLang uses the default values shown below.
Variables❖
The following variables can be added to your conf.py file:
# Marks the beginning of a DocLang command.
doclang_command_start = "§"
# Marks the end of a DocLang command.
doclang_command_end = "¶"
# Separate the command name from its arguments.
doclang_command_splitter = ":"
# Separate multiple arguments inside a command.
# Each character acts as an independent argument separator.
doclang_argument_separator = ",;"
# Separate keywords from their assigned values.
doclang_keyword_separator = "="
# Marks comments inside DocLang command blocks.
# Each character acts as an independent comment marker.
doclang_comment_marker = "#"
# Characters used to escape DocLang syntax when literal text is required.
# Each character acts as an independent escape marker.
doclang_escape_marker = "/|"
# Whether unknown/unregistered commands should be preserved instead of removed.
doclang_keep_unknown = False
# Whether commands validation should be performed.
doclang_validate_command = True
Syntax Rules❖
DocLang commands follow a simple pattern based on the configuration variables defined above. Understanding these rules will help you write correct and predictable command blocks inside your docstrings.
The sections below explain how each part of the syntax works.
Important
When customizing any syntax, be careful to avoid reusing characters.
Even if the sequences appear visually distinct, DocLang checks each character individually.
If any character is used more than once across all delimiters, splitters, separators or markers,
DocLang will raise an InvalidConfigError.
doclang_command_start = "<<"
doclang_command_end = ">>"
doclang_command_splitter = ">:<"
<< title >:< example splitter >>
Command Delimiters❖
# Marks the beginning of a DocLang command.
doclang_command_start = "§"
# Marks the end of a DocLang command.
doclang_command_end = "¶"
A command is always wrapped between the start and end markers:
§ command ¶
§ debug object ¶
Customization
The start and end markers are treated as complete units. If you configure them using multiple characters, the entire sequence must be used exactly as defined.
doclang_command_start = "<<"
doclang_command_end = ">>"
<< debug object >>
Note
The default command delimiters § and ¶ were chosen not only for their
visual clarity but also for their typing convenience. Both characters can be
entered easily on a standard keyboard with a numeric keypad:
§➜ ALT + 21¶➜ ALT + 20
This makes the default configuration comfortable to use even in workflows where DocLang commands are typed frequently.
Command Splitter❖
# Characters used to separate the command name from its arguments.
doclang_command_splitter = ":"
Most commands require one or more arguments. The splitter separates the command name from its arguments:
§ command : arguments ¶
§ title : example command ¶
Argument Separator❖
# Characters used to separate multiple arguments inside a command.
# Each character acts as a valid separator.
doclang_argument_separator = ",;"
Multiple arguments inside a command can be separated using any of the characters
defined in doclang_argument_separator. Each character is interpreted as an
independent separator.
§ list : width, height; depth ¶
Keyword Separator❖
# Character used to separate keywords from their assigned values.
doclang_keyword_separator = "="
Some commands support keyword/value pairs. The keyword separator defines the character used to assign a value to a keyword inside the argument block.
§ section : title = overview ¶
In this example, title is the keyword and Overview is the assigned value.
The keyword separator = makes the relationship explicit and easy to parse.
Escaping❖
# Characters used to escape DocLang syntax when literal text is required.
# Each character acts as an independent escape marker.
doclang_escape_marker = "/|"
DocLang provides an escape mechanism for situations where you need to include
characters that would normally be interpreted as part of a command. Any
character defined in doclang_escape_marker can be used to escape DocLang
syntax, allowing literal text to appear inside command blocks.
§ list : item 1, item 2/, item 3|, item 4 ¶
In this example, the last two commas are treated as literal text because they are prefixed with escape markers.
Unknown Commands❖
# Whether unknown/unregistered commands should be preserved instead of removed.
doclang_keep_unknown = False
By default, DocLang removes any command that is not registered or recognized by the processor. This ensures that accidental typos, incomplete commands or unsupported syntax do not appear in the generated documentation.
One § unknown command ¶ is here
Customization
When doclang_keep_unknown is set to True, unknown commands are preserved
exactly as written. This can be useful when experimenting with new command
patterns, integrating custom extensions or debugging command behavior.
doclang_keep_unknown = True
Other § unknown command ¶ is here
Validate Commands❖
# Whether commands validation should be performed.
doclang_validate_command = True
When this option is enabled, DocLang validates every command before it is registered or overwritten. The validation step ensures that the command can safely accept any number of arguments. If the command defines a return type hint and supports multiple arguments, it is considered valid immediately. Otherwise, DocLang simulates a call with a large number of arguments (up to 100) to verify that the implementation does not break when users provide more arguments than expected.
This mechanism ensures that all commands behave consistently inside the DSL, where arguments are always passed as plain strings and the number of arguments cannot be restricted.
Comments❖
DocLang allows comments inside command blocks. A comment begins with the configured marker and continues until the end of the command block. Comments are ignored during processing and do not affect the command output.
In this example, everything after
#is treated as a comment and removed before the command is evaluated.The comment marker configuration accepts multiple characters. Each character in the sequence is treated as a valid separator on its own.