From bfd7052c99301430ae1cc43c268e9850f662ccdd Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 17 Nov 2025 17:21:40 -0500 Subject: [PATCH 1/4] Move config to TOML We use a list instead of a dict and fix the CSS selector uniqueness programmatically instead of with manually appended spaces. --- Makefile | 3 +- README.md | 3 +- fix_html.py | 0 fix_index.py | 0 generate_dashing.py | 44 ++ .../sublime-merge.png | Bin resources/sublime-merge.toml | 97 +++++ .../sublime-text.png | Bin resources/sublime-text.toml | 348 ++++++++++++++++ sublime-merge-dashing.yml | 109 ----- sublime-text-dashing.yml | 392 ------------------ 11 files changed, 491 insertions(+), 505 deletions(-) mode change 100644 => 100755 fix_html.py mode change 100644 => 100755 fix_index.py create mode 100755 generate_dashing.py rename sublime-merge-icon.png => resources/sublime-merge.png (100%) create mode 100644 resources/sublime-merge.toml rename sublime-text-icon.png => resources/sublime-text.png (100%) create mode 100644 resources/sublime-text.toml delete mode 100644 sublime-merge-dashing.yml delete mode 100644 sublime-text-dashing.yml diff --git a/Makefile b/Makefile index e017978..35a1e56 100644 --- a/Makefile +++ b/Makefile @@ -25,12 +25,11 @@ pre-build: build: # Shared mkdir -p $(out_folder) + python generate_dashing.py # Sublime Text - yq -j . sublime-text-dashing.yml > $(st_site)/dashing.json cd $(st_site) && dashing build mv $(st_built_path) $(out_folder) # Sublime Merge - yq -j . sublime-merge-dashing.yml > $(sm_site)/dashing.json cd $(sm_site) && dashing build mv $(sm_built_path) $(out_folder) diff --git a/README.md b/README.md index d08f1bc..c8be0d3 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,7 @@ If you have default Linux folders, `make install-linux`. Otherwise: * `make` * [`dashing`][dashing] -* `yq` -* Python 3.8+ +* Python 3.11+ ### Steps diff --git a/fix_html.py b/fix_html.py old mode 100644 new mode 100755 diff --git a/fix_index.py b/fix_index.py old mode 100644 new mode 100755 diff --git a/generate_dashing.py b/generate_dashing.py new file mode 100755 index 0000000..bddc0c2 --- /dev/null +++ b/generate_dashing.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +""" +Mangles our tweaked TOML format into the `dashing` JSON format +""" +from tomllib import load +from json import dump + + +CONFIG_MAP = { + 'resources/sublime-text.toml': 'sublime-text/www.sublimetext.com/dashing.json', + 'resources/sublime-merge.toml': 'sublime-merge/www.sublimemerge.com/dashing.json', +} + + +for toml_path, json_path in CONFIG_MAP.items(): + with open(toml_path, 'rb') as f: + dashing = load(f) + + selector_list = dashing['selectors'] + selector_dict = {} + + for path in selector_list: + for obj in selector_list[path]: + if not obj: + continue + print(path, obj) + css = obj['css'] + while css in selector_dict: + css += ' ' + + item = { + **obj, + 'matchpath': fr'/{path}\.html$' if path else r'\.html$' + } + del item['css'] + + print(item) + selector_dict[css] = item + + dashing['selectors'] = selector_dict + print(dashing) + with open(json_path, 'w') as f: + dump(dashing, f, indent=4) diff --git a/sublime-merge-icon.png b/resources/sublime-merge.png similarity index 100% rename from sublime-merge-icon.png rename to resources/sublime-merge.png diff --git a/resources/sublime-merge.toml b/resources/sublime-merge.toml new file mode 100644 index 0000000..cd6e145 --- /dev/null +++ b/resources/sublime-merge.toml @@ -0,0 +1,97 @@ +# TOML to be slightly mangled into dashing.json +# https://github.com/technosophos/dashing#usage + +name = 'Sublime Merge' +package = 'sublime-merge' +index = 'docs/index.html' +icon32x32 = '../../resources/sublime-merge.png' +allowJS = false +ExternalURL = 'https://www.sublimemerge.com' +ignore = ['id', 'id0', 'id1', 'id2'] + +# Available 'type' values at +# # https://kapeli.com/docsets#supportedentrytypes + +[[selectors.'']] +# Each page's header +css = 'title' +type = 'Guide' + +[[selectors.'']] +# Page subheadings +css = 'h2' +type = 'Section' + + +[[selectors.faq]] +[[selectors.getting_started]] +[[selectors.diff_context]] + + +[[selectors.key_bindings]] +# Binding settings +css = 'section:has(#bindings) h3[id]' +type = 'Setting' + +[[selectors.key_bindings]] +# "context" modifiers +css = 'dt' +type = 'Filter' + + +[[selectors.command_palette]] +[[selectors.custom_commands]] +[[selectors.linux_repositories]] +[[selectors.command_line]] + + +[[selectors.themes]] +css = 'dl.attributes > dt' +type = 'Attribute' + +[[selectors.themes]] +css = 'dl.settings > dt' +type = 'Setting' + +[[selectors.themes]] +css = 'dl.properties > dt' +type = 'Property' + +[[selectors.themes]] +css = 'dl.elements > dt' +type = 'Element' + +[[selectors.themes]] +# Element properties +# TODO: Maybe split these into attributes and proporties +css = 'dl.elements > dd > dl dt code' +type = 'Property' + + +[[selectors.menus]] +# Settings +css = '.primary section:has(#entries) dt' +type = 'Setting' + +[[selectors.menus]] +# Variables +css = '.primary section:has(#available_menus) dl.enum > dt' +requiretext = '\$' +type = 'Variable' + +[[selectors.menus]] +# Menus +css = '.primary section:has(#available_menus) dl.enum > dt' +requiretext = '.sublime-menu' +type = 'File' + + +[[selectors.packages]] +css = 'dl dd' +type = 'File' + + +[[selectors.minihtml]] +css = 'li code:first-child' +requiretext = 'var' +type = 'Variable' diff --git a/sublime-text-icon.png b/resources/sublime-text.png similarity index 100% rename from sublime-text-icon.png rename to resources/sublime-text.png diff --git a/resources/sublime-text.toml b/resources/sublime-text.toml new file mode 100644 index 0000000..8fce459 --- /dev/null +++ b/resources/sublime-text.toml @@ -0,0 +1,348 @@ +# TOML to be slightly mangled into dashing.json +# https://github.com/technosophos/dashing#usage + +name = 'Sublime Text' +package = 'sublime-text' +index = 'docs/index.html' +icon32x32 = '../../resources/sublime-text.png' +allowJS = false +ExternalURL = 'https://www.sublimetext.com' +ignore = ['id', 'id0', 'id1', 'id2'] + +# Available 'type' values at +# # https://kapeli.com/docsets#supportedentrytypes + +[[selectors.'']] +# Each page's header +css = 'title' +type = 'Guide' + +[[selectors.'']] +# Page subheadings +css = 'h2' +type = 'Section' + + +[[selectors.git_integration]] +# Git status badges +css = '#status-badge-key .badges li' +type = 'Attribute' + +[[selectors.git_integration]] +# Commands and menus +css = 'ul li p' +type = 'Command' + +[[selectors.git_integration]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + + +[[selectors.incremental_diff]] +# Scopes as Tags +css = '#styling li p' +type = 'Tag' + +[[selectors.incremental_diff]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + + +[[selectors.indexing]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + + +[[selectors.command_line]] +[[selectors.multiple_selection_with_the_keyboard]] + + +[[selectors.completions]] +# Completion kinds +css = '#kind-info table.kinds td:not(:has(span))' +type = 'Value' + +[[selectors.completions]] +# Completion kinds again +css = '#rich-format dl.setting:has(#kind) ul.simple > li' +type = 'Value' + +[[selectors.completions]] +# Completion fields +css = '#completion-files dl.setting > dt' +type = 'Field' + +[[selectors.completions]] +# Snippet fields +css = '#snippets dl.setting > dt' +type = 'Field' + +[[selectors.completions]] +# Variables +css = '#variables table span.pre' +requiretext = '\$' +type = 'Variable' + +[[selectors.completions]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + + +[[selectors.distraction_free]] +# File +css = 'span.file' +type = 'File' + +[[selectors.distraction_free]] +# Settings +css = '.highlight .nt' +type = 'Setting' + + +[[selectors.vintage]] + + +[[selectors.projects]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + + +[[selectors.settings]] +# File +css = '#settings-files li span.file' +type = 'File' + + +[[selectors.key_bindings]] +# Bindings keys +css = '#bindings h3' +type = 'Setting' + +[[selectors.key_bindings]] +# "context" modifiers +css = '#context-key table code' +requiretext = '"' +type = 'Filter' + + +[[selectors.indentation]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + + +[[selectors.spell_checking]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + +[[selectors.spell_checking]] +css = '#commands code:first-child' +type = 'Command' + + +[[selectors.build_systems]] +# Options +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Option' + +[[selectors.build_systems]] +css = '#variables table code' +requiretext = '\$' +type = 'Variable' + + +[[selectors.packages]] +css = 'span.file' +type = 'File' + + +[[selectors.selectors]] + + +[[selectors.file_patterns]] +# "Uses" +css = '#uses li code' +type = 'Setting' + + +[[selectors.gpu_rendering]] +[[selectors.os_compatibility]] +[[selectors.linux_repositories]] + + +[[selectors.safe_mode]] +# Safe Mode data directories +css = 'span.file' +type = 'File' + +[[selectors.safe_mode]] +# Safe Mode command +css = '#starting pre' +type = 'Command' + + +[[selectors.revert]] +css = 'li span.file' +type = 'File' + + +[[selectors.side_by_side]] +[[selectors.previous_versions]] + + +[[selectors.ligatures]] +# Ligature options +css = '.s2 .pre' +type = 'Option' + + +[[selectors.portable_license_keys]] +css = 'li span.file' +type = 'File' + + +[[selectors.color_schemes]] +# Color functions +css = '#colors li b' +type = 'Function' + +[[selectors.color_schemes]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + +[[selectors.color_schemes]] +# Font styles +css = 'dt#font-style dd li code' +type = 'Value' + +[[selectors.color_schemes]] +# CSS colors +css = '#appendix-css-colors span:not(.color-block)' +type = 'Value' + + +[[selectors.themes]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + +[[selectors.themes]] +css = 'dl.themeprop > dt' +type = 'Property' + +[[selectors.themes]] +css = 'dl.themeclass > dt' +type = 'Element' + +[[selectors.themes]] +# Element properties +# TODO: Maybe split these into attributes and proporties +css = 'dl.themeclass > dd > dl dt code' +type = 'Property' + + +[[selectors.menus]] +css = 'dl.setting > dt[id]' +attr = 'id' +type = 'Setting' + +[[selectors.menus]] +css = '.subl .descname' +requiretext = '.sublime-menu' +type = 'File' + + +[[selectors.api_environments]] + + +[[selectors.api_reference]] +css = '#types dt.sig[id]' +attr = 'id' +type = 'Type' + +[[selectors.api_reference]] +css = '#sublime-module h2 code' +type = 'Module' + +[[selectors.api_reference]] +css = '#module-sublime_plugin h2 code' +type = 'Module' + +[[selectors.api_reference]] +css = 'dl.class > div > dt[id]' +attr = 'id' +type = 'Class' + +[[selectors.api_reference]] +css = 'dl.class > dt[id]' +attr = 'id' +type = 'Class' + +[[selectors.api_reference]] +css = 'dl.function > dt[id]' +attr = 'id' +type = 'Function' + +[[selectors.api_reference]] +css = 'dl.method > dt[id]' +attr = 'id' +type = 'Method' + +[[selectors.api_reference]] +css = 'dl.attribute > dt[id]' +attr = 'id' +type = 'Attribute' + + +[[selectors.syntax]] +css = '#header dl.setting > dt > span.sig-name' +type = 'Trait' + +[[selectors.syntax]] +css = '#contexts dl.setting > dt > span.sig-name' +type = 'Instruction' + +[[selectors.syntax]] +css = '#testing ul > li > p > code:first-child' +type = 'Test' + + +[[selectors.scope_naming]] +# Scope names as Tags +css = 'ul.simple li code' +type = 'Tag' + + +[[selectors.minihtml]] +css = '#tags li code' +requiretext = '<.+>' +type = 'Element' + +[[selectors.minihtml]] +css = '#attributes li code' +type = 'Attribute' + +[[selectors.minihtml]] +# CSS styles +css = '#css > ul li code:first-child' +type = 'Style' + +[[selectors.minihtml]] +# Color functions +css = '#color-mod-function-proprietary > ul li code' +type = 'Function' + +[[selectors.minihtml]] +css = '#predefined-variables > ul li code' +type = 'Variable' + + +[[selectors.porting_guide]] diff --git a/sublime-merge-dashing.yml b/sublime-merge-dashing.yml deleted file mode 100644 index e9d4712..0000000 --- a/sublime-merge-dashing.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Sublime Merge -package: sublime-merge -index: docs/index.html -icon32x32: ../../sublime-merge-icon.png -allowJS: false -ExternalURL: 'https://www.sublimemerge.com' -ignore: - - id - - id0 - - id1 - - id2 - -# https://github.com/technosophos/dashing?tab=readme-ov-file#usage -# https://kapeli.com/docsets#supportedentrytypes -selectors: - -###[ GLOBAL ]################################################################## - - # Each pages' header - title: - type: Guide - matchpath: '\.html$' - - # Page subheadings - h2: - type: Section - matchpath: '\.html$' - -###[ FAQ ]##################################################################### -###[ GETTING STARTED ]######################################################### -###[ DIFF CONTEXT ]############################################################ -###[ KEY BINDINGS ]############################################################ - - # Binding settings - 'section:has(#bindings) h3[id]': - type: Setting - matchpath: '/key_bindings\.html$' - - # "context" modifiers - 'dt': - type: Filter - matchpath: '/key_bindings\.html$' - -###[ COMMAND PALETTE ]######################################################### -###[ CUSTOM COMMANDS ]######################################################### -###[ COMMAND LINE ]############################################################ -###[ THEMES ]################################################################## - - # Attributes - 'dl.attribute > dt': - type: Attribute - matchpath: '/themes\.html$' - - # Settings - 'dl.settings > dt': - type: Setting - matchpath: '/themes\.html$' - - # Properties - 'dl.properties > dt': - type: Property - matchpath: '/themes\.html$' - - # Theme elements - 'dl.elements > dt': - type: Element - matchpath: '/themes\.html$' - - # Element properties - # TODO: Maybe split these into attributes and properties - 'dl.elements > dd > dl dt code': - type: Property - matchpath: '/themes\.html$' - -###[ MENUS ]################################################################### - - # Settings - '.primary section:has(#entries) dt': - type: Setting - matchpath: '/menus\.html$' - - # Variables - '.primary section:has(#available_menus) dl.enum > dt': - requiretext: '\$' - type: Variable - matchpath: '/menus\.html$' - - # Menus - # (Extra trailing space to avoid JSON dict key overload) - '.primary section:has(#available_menus) dl.enum > dt ': - requiretext: '.sublime-menu' - type: File - matchpath: '/menus\.html$' - -###[ PACKAGES ]################################################################ - - # Files - 'dl dd': - type: File - matchpath: '/packages\.html$' - -###[ MINIHTML REFERENCE ]###################################################### - - # Variables - 'li code:first-child': - requiretext: 'var' - type: Variable - matchpath: '/minihtml\.html$' - diff --git a/sublime-text-dashing.yml b/sublime-text-dashing.yml deleted file mode 100644 index 535e19c..0000000 --- a/sublime-text-dashing.yml +++ /dev/null @@ -1,392 +0,0 @@ -name: Sublime Text -package: sublime-text -index: docs/index.html -icon32x32: ../../sublime-text-icon.png -allowJS: false -ExternalURL: 'https://www.sublimetext.com' -ignore: - - id - - id0 - - id1 - - id2 - -# https://github.com/technosophos/dashing?tab=readme-ov-file#usage -# https://kapeli.com/docsets#supportedentrytypes -selectors: - -###[ GLOBAL ]################################################################## - - # Each pages' header - title: - type: Guide - matchpath: '\.html$' - - # Page subheadings - h2: - type: Section - matchpath: '\.html$' - -###[ TAB MULTI-SELECT ]######################################################## -###[ GIT INTEGRATION ]######################################################### - - # Git Status badges - '#status-badge-key .badges li': - type: Attribute - matchpath: '/git_integration\.html$' - - # Commands and menus - 'ul li p': - type: Command - matchpath: '/git_integration\.html$' - - # Settings - 'dl.setting > dt[id]': - attr: id - type: Setting - matchpath: '/git_integration\.html$' - -###[ INCREMENTAL DIFF ]######################################################## - - # Scopes as Tags - '#styling li p': - type: Tag - matchpath: '/incremental_diff\.html$' - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/incremental_diff\.html$' - -###[ INDEXING ]################################################################ - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/indexing\.html$' - -###[ COMMAND LINE INTERFACE ]################################################## -###[ MULTIPLE SELECTION ]###################################################### -###[ COMPLETIONS ]############################################################# - - # Completion kinds - '#kind-info table.kinds td:not(:has(span))': - type: Value - matchpath: '/completions\.html$' - - # Completion kinds again - '#rich-format dl.setting:has(#kind) ul.simple > li': - type: Value - matchpath: '/completions\.html$' - - # Completion fields - '#completion-files dl.setting > dt': - type: Field - matchpath: '/completions\.html$' - - # Snippet fields - '#snippets dl.setting > dt': - type: Field - matchpath: '/completions\.html$' - - # Variables - '#variables table span.pre': - type: Variable - requiretext: '\$' - matchpath: '/completions\.html$' - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/completions\.html$' - -###[ DISTRACTION FREE MODE ]################################################### - - # File - 'span.file': - type: File - matchpath: '/distraction_free\.html$' - - # Settings - '.highlight .nt': - type: Setting - matchpath: '/distraction_free\.html$' - -###[ VINTAGE MODE ]############################################################ -###[ PROJECTS ]################################################################ - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/projects\.html$' - -###[ SETTINGS ]################################################################ - - # Files - '#settings-files span.file': - type: File - matchpath: '/settings\.html$' - -###[ KEY BINDINGS ]############################################################ - - # Bindings keys - '#bindings h3': - type: Setting - matchpath: '/key_bindings\.html$' - - # "context" modifiers - '#context-key table code': - type: Filter - requiretext: '"' - matchpath: '/key_bindings\.html$' - -###[ FONT SETTINGS ]########################################################### -###[ INDENTATION SETTINGS ]#################################################### - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/indentation\.html$' - -###[ SPELL CHECKING ]########################################################## - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/spell_checking\.html$' - - # Commands - '#commands code:first-child': - type: Command - matchpath: '/spell_checking\.html$' - -###[ BUILD SYSTEMS ]########################################################### - - # Options - 'dl.setting > dt[id] ': - attr: id - type: Option - matchpath: '/build_systems\.html$' - - # Variables - '#variables table code': - type: Variable - requiretext: '\$' - matchpath: '/build_systems\.html$' - -###[ PACKAGES ]################################################################ - - # Files - 'li span.file ': - type: File - matchpath: '/packages\.html$' - -###[ SELECTORS ]############################################################### -###[ FILE PATTERNS ]########################################################### - - # "Uses" - '#uses li code': - type: Setting - matchpath: '/file_patterns\.html$' - -###[ GPU RENDERING ]########################################################### -###[ OPERATING SYSTEM COMPATIBILITY ]########################################## -###[ LINUX PACKAGE MANAGER REPOSITORIES ]###################################### -###[ SAFE MODE ]############################################################### - - # Safe Mode Data Dir - '#behavior > ul li span.file': - type: File - matchpath: '/safe_mode\.html$' - - # Safe Mode command - '#starting pre': - type: Command - matchpath: '/safe_mode\.html$' - -###[ REVERTING TO A FRESHLY INSTALLED STATE ]################################## - - # Files - 'li span.file ': - type: File - matchpath: '/revert\.html$' - -###[ RUNNING 3 AND 4 SIDE BY SIDE ]############################################ -###[ ACCESSING PREVIOUS VERSIONS ]############################################# -###[ LIGATURES ]############################################################### - - # Options - '.s2 .pre': - type: Option - matchpath: '/ligatures\.html$' - -###[ PORTABLE LICENSE KEYS ]################################################### - - # Files - 'li span.file': - type: File - matchpath: '/portable_license_keys\.html$' - -###[ COLOR SCHEMES ]########################################################### - - # Color functions - '#colors li b': - type: Function - matchpath: '/color_schemes\.html$' - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/color_schemes\.html$' - - # Font Styles - 'dt#font-style dd li code': - type: Value - matchpath: '/color_schemes\.html$' - - # CSS Colors - '#appendix-css-colors span:not(.color-block)': - type: Value - matchpath: '/color_schemes\.html$' - -###[ THEMES ]################################################################## - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/themes\.html$' - - # Properties - 'dl.themeprop > dt': - type: Property - matchpath: '/themes\.html$' - - # Theme elements - 'dl.themeclass > dt': - type: Element - matchpath: '/themes\.html$' - - # Element properties - # TODO: Maybe split these into attributes and properties - 'dl.themeclass > dd > dl dt code': - type: Property - matchpath: '/themes\.html$' - -###[ MENUS ]################################################################### - - # Settings - 'dl.setting > dt[id] ': - attr: id - type: Setting - matchpath: '/menus\.html$' - - '.subl .descname': - requiretext: '.sublime-menu' - type: File - matchpath: '/menus\.html$' - -###[ API ENVIRONMENTS ]######################################################## -###[ API REFERENCE ]########################################################### - - # Types - '#types dt.sig[id]': - attr: id - type: Type - matchpath: '/api_reference\.html$' - - # Modules - '#sublime-module h2 code': - type: Module - matchpath: 'api_reference\.html$' - '#module-sublime_plugin h2 code': - type: Module - matchpath: '/api_reference\.html$' - - # Classes - 'dl.class > div > dt[id]': - attr: id - type: Class - matchpath: 'api_reference\.html$' - 'dl.class > dt[id]': - attr: id - type: Class - matchpath: '/api_reference\.html$' - - # Functions - 'dl.function > dt[id]': - attr: id - type: Function - matchpath: '/api_reference\.html$' - - # Methods - 'dl.method > dt[id]': - attr: id - type: Method - matchpath: '/api_reference\.html$' - - # Attributes - 'dl.attribute > dt[id]': - attr: id - type: Attribute - matchpath: '/api_reference\.html$' - -###[ SYNTAX DEFINITIONS ]###################################################### - - # Syntax header - '#header dl.setting > dt > span.sig-name': - type: Trait - matchpath: '/syntax\.html$' - - # Syntax body - '#contexts dl.setting > dt > span.sig-name': - type: Instruction - matchpath: '/syntax\.html$' - - # Index tests - '#testing ul > li > p > code:first-child': - type: Test - matchpath: '/syntax\.html$' - -###[ SCOPE NAMING ]############################################################ - - # Scope names as Tags - 'ul.simple li code': - type: Tag - matchpath: '/scope_naming\.html$' - -###[ MINIHTML REFERENCE ]###################################################### - - # Elements - '#tags li code': - type: Element - requiretext: '<.+>' - matchpath: '/minihtml\.html$' - - # Attributes - '#attributes li code': - type: Attribute - matchpath: '/minihtml\.html$' - - # CSS styles - '#css > ul li code:first-child': - type: Style - matchpath: '/minihtml\.html$' - - # Color functions - '#color-mod-function-proprietary > ul li code': - type: Function - matchpath: '/minihtml\.html$' - - # Variables - '#predefined-variables > ul li code': - type: Variable - matchpath: '/minihtml\.html$' - -###[ PLUGIN PORTING GUIDE ]#################################################### From c6c6bfcbbce9ddf47a370f6fbf3b5f1db58b25f2 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 18 Nov 2025 09:46:52 -0500 Subject: [PATCH 2/4] Format the TOML mangler --- generate_dashing.py | 57 +++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/generate_dashing.py b/generate_dashing.py index bddc0c2..64c4c52 100755 --- a/generate_dashing.py +++ b/generate_dashing.py @@ -3,42 +3,49 @@ """ Mangles our tweaked TOML format into the `dashing` JSON format """ +import sys + from tomllib import load from json import dump - CONFIG_MAP = { 'resources/sublime-text.toml': 'sublime-text/www.sublimetext.com/dashing.json', 'resources/sublime-merge.toml': 'sublime-merge/www.sublimemerge.com/dashing.json', } -for toml_path, json_path in CONFIG_MAP.items(): - with open(toml_path, 'rb') as f: - dashing = load(f) +def main(): + for toml_path, json_path in CONFIG_MAP.items(): + with open(toml_path, 'rb') as f: + dashing = load(f) + + selector_list = dashing['selectors'] + selector_dict = {} + + for path in selector_list: + for toml_item in selector_list[path]: + if not toml_item: + continue + + # Pad the selector until it is unique + css = toml_item['css'] + while css in selector_dict: + css += ' ' + + json_item = { + **toml_item, + 'matchpath': fr'/{path}\.html$' if path else r'\.html$', + } + del json_item['css'] - selector_list = dashing['selectors'] - selector_dict = {} + selector_dict[css] = json_item - for path in selector_list: - for obj in selector_list[path]: - if not obj: - continue - print(path, obj) - css = obj['css'] - while css in selector_dict: - css += ' ' + # Replace [selectors] with the `dashing` format + dashing['selectors'] = selector_dict - item = { - **obj, - 'matchpath': fr'/{path}\.html$' if path else r'\.html$' - } - del item['css'] + with open(json_path, 'w') as f: + dump(dashing, f, indent=4) - print(item) - selector_dict[css] = item - dashing['selectors'] = selector_dict - print(dashing) - with open(json_path, 'w') as f: - dump(dashing, f, indent=4) +if __name__ == '__main__': + sys.exit(main()) From 9887b3f93fd98b5be7aaacbbb7c7d1b7475ca0ad Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 18 Nov 2025 09:58:52 -0500 Subject: [PATCH 3/4] Use more explicit titles for global rules --- generate_dashing.py | 42 +++++++++++++++++++----------------- resources/sublime-merge.toml | 4 ++-- resources/sublime-text.toml | 4 ++-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/generate_dashing.py b/generate_dashing.py index 64c4c52..27c90ee 100755 --- a/generate_dashing.py +++ b/generate_dashing.py @@ -19,32 +19,34 @@ def main(): with open(toml_path, 'rb') as f: dashing = load(f) - selector_list = dashing['selectors'] - selector_dict = {} + selector_list = dashing['selectors'] + selector_dict = {} - for path in selector_list: - for toml_item in selector_list[path]: - if not toml_item: - continue + for path in selector_list: + for toml_item in selector_list[path]: + if not toml_item: + continue - # Pad the selector until it is unique - css = toml_item['css'] - while css in selector_dict: - css += ' ' + # Pad the selector until it is unique + css = toml_item['css'] + while css in selector_dict: + css += ' ' - json_item = { - **toml_item, - 'matchpath': fr'/{path}\.html$' if path else r'\.html$', - } - del json_item['css'] + matchpath = fr'/{path}\.html$' + if path == 'GLOBAL': + matchpath = r'\.html$' - selector_dict[css] = json_item + json_item = toml_item + json_item['matchpath'] = matchpath + del json_item['css'] - # Replace [selectors] with the `dashing` format - dashing['selectors'] = selector_dict + selector_dict[css] = json_item - with open(json_path, 'w') as f: - dump(dashing, f, indent=4) + # Replace [selectors] with the `dashing` format + dashing['selectors'] = selector_dict + + with open(json_path, 'w') as f: + dump(dashing, f, indent=4) if __name__ == '__main__': diff --git a/resources/sublime-merge.toml b/resources/sublime-merge.toml index cd6e145..440b972 100644 --- a/resources/sublime-merge.toml +++ b/resources/sublime-merge.toml @@ -12,12 +12,12 @@ ignore = ['id', 'id0', 'id1', 'id2'] # Available 'type' values at # # https://kapeli.com/docsets#supportedentrytypes -[[selectors.'']] +[[selectors.GLOBAL]] # Each page's header css = 'title' type = 'Guide' -[[selectors.'']] +[[selectors.GLOBAL]] # Page subheadings css = 'h2' type = 'Section' diff --git a/resources/sublime-text.toml b/resources/sublime-text.toml index 8fce459..1e63c7a 100644 --- a/resources/sublime-text.toml +++ b/resources/sublime-text.toml @@ -12,12 +12,12 @@ ignore = ['id', 'id0', 'id1', 'id2'] # Available 'type' values at # # https://kapeli.com/docsets#supportedentrytypes -[[selectors.'']] +[[selectors.GLOBAL]] # Each page's header css = 'title' type = 'Guide' -[[selectors.'']] +[[selectors.GLOBAL]] # Page subheadings css = 'h2' type = 'Section' From 63f3e8d556f89584597ff377e6da1bca1484a5cf Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 18 Nov 2025 10:45:44 -0500 Subject: [PATCH 4/4] Move the Python files --- Makefile | 6 +++--- fix_html.py => src/fix_html.py | 4 ++-- fix_index.py => src/fix_index.py | 2 +- generate_dashing.py => src/generate_dashing.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename fix_html.py => src/fix_html.py (94%) rename fix_index.py => src/fix_index.py (96%) rename generate_dashing.py => src/generate_dashing.py (87%) diff --git a/Makefile b/Makefile index 35a1e56..551c468 100644 --- a/Makefile +++ b/Makefile @@ -20,12 +20,12 @@ sm_built_path := $(sm_site)/$(sm_docset) all: clean pre-build build post-build test pre-build: - python fix_html.py + cd src && python fix_html.py build: # Shared mkdir -p $(out_folder) - python generate_dashing.py + cd src && python generate_dashing.py # Sublime Text cd $(st_site) && dashing build mv $(st_built_path) $(out_folder) @@ -34,7 +34,7 @@ build: mv $(sm_built_path) $(out_folder) post-build: - python fix_index.py + cd src && python fix_index.py .PHONY: clean clean: diff --git a/fix_html.py b/src/fix_html.py similarity index 94% rename from fix_html.py rename to src/fix_html.py index be96273..01853f6 100755 --- a/fix_html.py +++ b/src/fix_html.py @@ -10,8 +10,8 @@ from bs4 import BeautifulSoup DOC_ROOTS = [ - 'sublime-text/www.sublimetext.com/docs', - 'sublime-merge/www.sublimemerge.com/docs', + '../sublime-text/www.sublimetext.com/docs', + '../sublime-merge/www.sublimemerge.com/docs', ] diff --git a/fix_index.py b/src/fix_index.py similarity index 96% rename from fix_index.py rename to src/fix_index.py index 637c563..74715e5 100755 --- a/fix_index.py +++ b/src/fix_index.py @@ -6,7 +6,7 @@ import sys import sqlite3 -SQLITE_PATH_FMT = 'out/{}/Contents/Resources/docSet.dsidx' +SQLITE_PATH_FMT = '../out/{}/Contents/Resources/docSet.dsidx' DOCSET_FIXES = { 'sublime-text.docset': [ ('docs/distraction_free.html', diff --git a/generate_dashing.py b/src/generate_dashing.py similarity index 87% rename from generate_dashing.py rename to src/generate_dashing.py index 27c90ee..52e34c8 100755 --- a/generate_dashing.py +++ b/src/generate_dashing.py @@ -9,8 +9,8 @@ from json import dump CONFIG_MAP = { - 'resources/sublime-text.toml': 'sublime-text/www.sublimetext.com/dashing.json', - 'resources/sublime-merge.toml': 'sublime-merge/www.sublimemerge.com/dashing.json', + '../resources/sublime-text.toml': '../sublime-text/www.sublimetext.com/dashing.json', + '../resources/sublime-merge.toml': '../sublime-merge/www.sublimemerge.com/dashing.json', }