diff --git a/docs.py b/docs.py index a5f24fb..3eedd32 100644 --- a/docs.py +++ b/docs.py @@ -8,6 +8,7 @@ from livereload import Server # Importing performs monkeypatching import xml_lexer # NOQA: F401 +import ini_lexer # NOQA: F401 app = Flask(__name__) @@ -52,6 +53,7 @@ SEGA_CONTENTS = { "dongle.html": "Dongles", "keychip.html": "Keychips", }), + "groovemaster.html": "GrooveMaster.ini", }), "network": ("Networking", { "allnet.html": "ALL.Net" @@ -73,14 +75,20 @@ class Part: PARTS = { "838-14971": Part("838-14971", "Aime NFC daughter board", "NFC RW BD TN32MSEC003S"), - "838-15221": Part("838-15221", "Serial I/F BD Touchpanel Gunze", "The interface board for the touchscreen on MaiMai versions pre-DX.") + "838-15221": Part("838-15221", "Serial I/F BD Touchpanel Gunze", + "The interface board for the touchscreen on MaiMai versions pre-DX.") } -def part(id): - if (part := PARTS.get(id)): - return f'{part.name}ASSY IDSEGA {part.id}Description{part.description}' - return f'{id}' +def part(id_): + if (part := PARTS.get(id_)): + return ( + f'{part.name}' + f'ASSY IDSEGA {part.id}' + f'Description{part.description}' + '' + ) + return f'{id_}' def generate_xrpc_list(): @@ -355,7 +363,7 @@ def sitemap(): return response -if __name__ == '__main__': +def run_dev(): app.config['TEMPLATES_AUTO_RELOAD'] = True app.config['DEBUG'] = True @@ -364,3 +372,7 @@ if __name__ == '__main__': server = Server(app.wsgi_app) server.watch(".") server.serve(port=3000) + + +if __name__ == '__main__': + run_dev() diff --git a/ini_lexer.py b/ini_lexer.py new file mode 100644 index 0000000..225a63b --- /dev/null +++ b/ini_lexer.py @@ -0,0 +1,68 @@ +# from pygments.lexer import RegexLexer +# from pygments.token import Text, Comment, Operator, Name, String +# from pygments.lexers import _lexer_cache +# from pygments.lexers._mapping import LEXERS + +# def italic_attr(lexer, m): +# yield m.start(), String, '"' +# yield m.start() + 2, Comment, m.group()[3:-1] +# yield m.end() - 1, String, '"' + + +# def italic_generic(lexer, m): +# yield m.start(), Comment, m.group() + + +# def italic_tag(lexer, m): +# yield m.start(), Name.Tag, "<" +# name = m.group()[3:] +# if name.endswith(">"): +# yield m.start() + 1, Comment, name[:-1] +# yield m.end() - 1, Name.Tag, ">" +# else: +# yield m.start() + 1, Comment, name + + +# def italic_tag_close(lexer, m): +# yield m.start(), Name.Tag, "" +# yield m.start() + 4, Comment, m.group()[4:-1] +# yield m.end() - 1, Name.Tag, ">" + + +# def repeat_tag_close(lexer, m): +# before, _, after = m.group().partition("[]") +# yield m.start(), Name.Tag, before +# yield m.start() + len(before), Operator, "[]" +# yield m.start() + len(before) + 2, Name.Tag, after + + +# def italic_attr_name(lexer, m): +# name, _, after = m.group().partition("*") +# yield m.start(), Name.Attribute, name +# yield m.start() + len(name), Operator, "*" +# yield m.start() + len(name) + 1, Name.Attribute, after + +from pygments.lexer import RegexLexer, bygroups +from pygments.token import Comment, Name, String, Whitespace +from pygments.lexers import _lexer_cache +from pygments.lexers._mapping import LEXERS + + +class CustomIniLexer(RegexLexer): + name = 'amINI' + aliases = ['amini'] + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'[;#].*', Comment.Single), + (r'([a-zA-Z0-9]+?)([ \t]+)([a-zA-Z0-9]+)', bygroups(Name.Attribute, Whitespace, String)), + ] + } + + +_lexer_cache[CustomIniLexer.__name__] = CustomIniLexer + +LEXERS["CustomIniLexer"] = ("ini_lexer", "CustomIniLexer", ("amini", ), (), ()) + +__all__ = ("CustomIniLexer", ) diff --git a/templates/base.html b/templates/base.html index 465d876..c6b3cc5 100644 --- a/templates/base.html +++ b/templates/base.html @@ -23,7 +23,7 @@
{% block rootbody %}{% endblock %} {{ generate_footer()|safe }} - +