943acbc573
Durcit la convention de nommage des projets (dérive constatée : 'Sliding Automation', 'code_versioning'... au lieu des formes canoniques). - trilium_api.py : projets_canoniques() lit le référentiel = valeurs du label projet sur les notes de type=projet (source unique, pas de constante en dur). Note-projet CodeVersioning créée (manquait). - mcp_server.py : _valider_projet() branché dans les 6 tools de création (add_decision/history/backlog, new_conversation, create_entite, add_skill). Refuse un projet non canonique (suggestion si faute) ou inconnu (renvoi au processus de création de projet). Ne verrouille pas si référentiel illisible. - lint_audit.py : VAL-nommage aligné sur le référentiel (attrape casse, espace ET snake_case ; l'ancien 'contient un espace' ratait code_versioning). - Données : 79 notes ré-étiquetées vers les 3 formes canoniques. Quality by design : l'erreur de nommage devient impossible à l'écriture, le Lint n'est plus que le filet de sécurité.
75 lines
1.9 KiB
Python
75 lines
1.9 KiB
Python
"""
|
|
pygments.plugin
|
|
~~~~~~~~~~~~~~~
|
|
|
|
Pygments plugin interface.
|
|
|
|
lexer plugins::
|
|
|
|
[pygments.lexers]
|
|
yourlexer = yourmodule:YourLexer
|
|
|
|
formatter plugins::
|
|
|
|
[pygments.formatters]
|
|
yourformatter = yourformatter:YourFormatter
|
|
/.ext = yourformatter:YourFormatter
|
|
|
|
As you can see, you can define extensions for the formatter
|
|
with a leading slash.
|
|
|
|
syntax plugins::
|
|
|
|
[pygments.styles]
|
|
yourstyle = yourstyle:YourStyle
|
|
|
|
filter plugin::
|
|
|
|
[pygments.filter]
|
|
yourfilter = yourfilter:YourFilter
|
|
|
|
|
|
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
|
:license: BSD, see LICENSE for details.
|
|
"""
|
|
import functools
|
|
from importlib.metadata import entry_points
|
|
|
|
LEXER_ENTRY_POINT = 'pygments.lexers'
|
|
FORMATTER_ENTRY_POINT = 'pygments.formatters'
|
|
STYLE_ENTRY_POINT = 'pygments.styles'
|
|
FILTER_ENTRY_POINT = 'pygments.filters'
|
|
|
|
|
|
@functools.cache
|
|
def iter_entry_points(group_name):
|
|
groups = entry_points()
|
|
if hasattr(groups, 'select'):
|
|
# New interface in Python 3.10 and newer versions of the
|
|
# importlib_metadata backport.
|
|
return groups.select(group=group_name)
|
|
else:
|
|
# Older interface, deprecated in Python 3.10 and recent
|
|
# importlib_metadata, but we need it in Python 3.8 and 3.9.
|
|
return groups.get(group_name, [])
|
|
|
|
|
|
def find_plugin_lexers():
|
|
for entrypoint in iter_entry_points(LEXER_ENTRY_POINT):
|
|
yield entrypoint.load()
|
|
|
|
|
|
def find_plugin_formatters():
|
|
for entrypoint in iter_entry_points(FORMATTER_ENTRY_POINT):
|
|
yield entrypoint.name, entrypoint.load()
|
|
|
|
|
|
def find_plugin_styles():
|
|
for entrypoint in iter_entry_points(STYLE_ENTRY_POINT):
|
|
yield entrypoint.name, entrypoint.load()
|
|
|
|
|
|
def find_plugin_filters():
|
|
for entrypoint in iter_entry_points(FILTER_ENTRY_POINT):
|
|
yield entrypoint.name, entrypoint.load()
|