Base Feature Class¶
FLM feature plugin system.
Features are the primary extension mechanism in FLM. Each feature defines a set of macros, environments, and/or specials that can be used in FLM documents. Features are pluggable: you can enable, disable, and configure them independently.
To define a custom feature, subclass Feature (or
SimpleLatexDefinitionsFeature for features that only need to
provide LaTeX context definitions without document/render managers).
See standard_features() for the default set of
features shipped with FLM.
- class flm.feature.Feature¶
Base class to implement a FLM feature (extension).
- feature_dependencies: Set[str] | Sequence[str] | None = None¶
If non-None, then this is a list (or set) of feature names that must also be used in a given
FLMEnvironmentinstance for the present feature to function as intended. These dependency features will be initialized prior to the present feature.
- feature_optional_dependencies: Set[str] | Sequence[str] | None = None¶
If non-None, then this is a list (or set) of feature names that may enhance the functionality of the present feature. If these features are activated, they will be initialized prior to the present feature.
- feature_default_config: Mapping = {}¶
The default configuration tree for this feature. The
runmodule uses these defaults when no configuration is specified for a given feature. Recall that the configuration is a dictionary of key/value pairs that will be specified byrunas keyword arguments to the constructor of the feature instance. If you create feature instances yourself, then you’re responsible anyways for the arguments you specify to the constructor, and you are responsible for honoring or ignoring the values in feature_default_config.
- DocumentManager¶
alias of
FeatureDocumentManagerBase
- RenderManager¶
alias of
FeatureRenderManagerBase
- add_latex_context_definitions() None | TypeDictWithLatexContextDefinitions¶
Override to provide macro, environment, and specials definitions for this feature.
- Returns:
A dictionary with optional keys
'macros','environments', and'specials', whose values are lists ofFLMMacroSpecBase,FLMEnvironmentSpecBase, andFLMSpecialsSpecBaseinstances respectively. Return an empty dict orNoneif no definitions are needed.
- classmethod get_node_id(node) Hashable¶
Helper method to get a unique hashable identifier key (integer or tuple) associated with the object node. The result can be used for instance as a dictionary key to store data that needs to be associated with a given object instance or with given unique identifying information.
The argument node is assumed to be either an object instance (e.g., a LatexNode instance) or a tuple of hashable data. In the first case, this method essentially returns the object’s id(node), providing a unique key associated with that object instance, and in the latter case, the tuple is returned as is.
- class flm.feature.SimpleLatexDefinitionsFeature¶
A simple feature base class whose only purpose is to provide additional LaTeX definitions to the latex context of the parser, without any document or render managers.
- latex_definitions: TypeDictWithLatexContextDefinitions = {}¶
Set to a dictionary with one or more of the keys (‘macros’, ‘environments’, ‘specials’), whose corresponding values are lists of FLMMacroSpec, FLMEnvironmentSpec, and FLMSpecialsSpec instances.