API Reference¶
Data Types¶
- type sphinxnotes.render.PlainValue = bool | int | float | str | object¶
- type sphinxnotes.render.Value = None | PlainValue | list[PlainValue]¶
- class sphinxnotes.render.RawData(name: 'str | None', attrs: 'dict[str, str]', content: 'str | None')¶
- Parameters:
name (str | None)
attrs (dict[str, str])
content (str | None)
- class sphinxnotes.render.ParsedData(name: 'Value', attrs: 'dict[str, Value]', content: 'Value')¶
- Parameters:
name (Value)
attrs (dict[str, Value])
content (Value)
- class sphinxnotes.render.Field(etype: 'type' = <class 'str'>, ctype: 'type | None' = None, flags: 'dict[str, Value]'=<factory>, dsl: 'str | None' = None)¶
- Parameters:
etype (type)
ctype (type | None)
flags (dict[str, Value])
dsl (str | None)
- class sphinxnotes.render.Schema(name: 'Field | None', attrs: 'dict[str, Field] | Field', content: 'Field | None')¶
- class sphinxnotes.render.data.Registry¶
Stores supported element types and element forms (containers).
- add_type(name, etype, conv, strify, aliases=[])¶
Register a value type for
PlainValue.- Parameters:
name (str) – The name for this scalar type, available as a Type modifier in the DSL
etype (type) – The Python type object
conv (Callable[[str], PlainValue]) – A callable that converts a string to the etype
strify (Callable[[PlainValue], str]) – A callable that converts the etype to a string
aliases (list[str]) – Alternative names for this type
- Return type:
None
See also
- add_form(name, ctype, sep, aliases=[])¶
Register an value form with its container type and separator for
Value.- Parameters:
name (str) – The name for this form, available as a Form modifier in the DSL
ctype (type) – The container type. (for now, it is
list,tuple, orset)sep (str) – The separator string used to split/join values
aliases (list[str]) – Alternative names for this form
- Return type:
None
- add_flag(name, default=False, aliases=[])¶
Register a flag.
- Parameters:
name (str) – The name for this flag, available as a Flag in the DSL
default (bool) – The default value for this flag
aliases (list[str]) – Alternative names for this flag
- Return type:
None
See also
- add_by_option(name, etype, default=None, store='assign', aliases=[])¶
Register a by-option.
- Parameters:
name (str) – The name for this option, available as a By-Option in the DSL
etype (type) – The value type for this option
default (Value) – The default value for this option
store (ByOptionStore) – How to store multiple values
aliases (list[str]) – Alternative names for this option
- Return type:
None
See also
- type ByOptionStore = Literal['assign', 'append']¶
The Render Pipeline¶
Context¶
- class sphinxnotes.render.PendingContext¶
A abstract representation of context that is not currently available.
Call
resolve()at the right time (depends on the implment) to get context available.
- type sphinxnotes.render.ResolvedContext = ParsedData | dict[str, Any]¶
- class sphinxnotes.render.UnparsedData(raw, schema)¶
A implementation of PendingContext, contains raw data and its schema.
- class sphinxnotes.render.pending_node(ctx, tmpl, inline=False, rawsource='', *children, **attributes)¶
- Parameters:
ctx (PendingContext | ResolvedContext)
tmpl (Template)
inline (bool)
Extra Context¶
- class sphinxnotes.render.ExtraContextGenerator(node)¶
- Parameters:
node (pending_node)
- class sphinxnotes.render.ExtraContextRegistry¶
Template¶
- class sphinxnotes.render.Template(text: 'str', phase: 'Phase' = <Phase.Parsing: 'parsing'>, debug: 'bool' = False)¶
- Parameters:
text (str)
phase (Phase)
debug (bool)
- class sphinxnotes.render.Phase(*values)¶
Pipeline¶
- class sphinxnotes.render.BaseContextRole¶
- class sphinxnotes.render.BaseContextDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)¶
- class sphinxnotes.render.BaseDataDefineRole¶
- class sphinxnotes.render.BaseDataDefineDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)¶
- class sphinxnotes.render.StrictDataDefineDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)¶
Registry¶
- sphinxnotes.render.REGISTRY = <sphinxnotes.render.Registry object>¶
The global, all-in-one registry for user.
- class sphinxnotes.render.Registry¶
The global, all-in-one registry for user.
- property extra_context: ExtraContextRegistry¶