@carlwr/docopt-tmlanguage 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Carl Wernhoff
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # docopt.tmLanguage
2
+
3
+ A TextMate grammar for _docopt-style command synopsis notation_ — which may look like e.g.:
4
+
5
+ ```
6
+ cat [OPTION]... [FILE]...
7
+
8
+ cd [ -qsLP ] {+|-}n
9
+
10
+ prog -a [-bc -e param] --arg0 val0 --arg1=val1
11
+
12
+ prog <thing> [[+-]feature ...]
13
+ ```
14
+
15
+ The closest to an authoritative "docopt spec" would be [POSIX _12.1 Utility Argument Syntax_][posix-12.1] or [docopt.org]. The grammar generally supports the syntax each of these specify, but also accommodates other forms commonly seen in the wild, e.g. `prog {+|-}`.
16
+
17
+ ## AI/human authorship
18
+
19
+ This `README.md` file [is written by](./AGENTS.md) me, Carl, a human developer. The grammar itself is written by LLMs.
20
+
21
+ ## Similar/related grammars
22
+
23
+ - https://github.com/Vallentin/vscode-bnf (`bnf.tmLanguage`)
24
+ - https://github.com/victor-gp/cmd-help-sublime-syntax (`text.cmd-help`)
25
+
26
+ ## References
27
+
28
+ - [POSIX _12.1 Utility Argument Syntax_][posix-12.1]
29
+ - [docopt.org]
30
+
31
+ [posix-12.1]: https://pubs.opengroup.org/onlinepubs/9799919799/
32
+ [docopt.org]: http://docopt.org/
@@ -0,0 +1,160 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
+ "name": "docopt",
4
+ "scopeName": "source.docopt",
5
+ "patterns": [
6
+ {
7
+ "include": "#tokens"
8
+ }
9
+ ],
10
+ "repository": {
11
+ "tokens": {
12
+ "patterns": [
13
+ { "include": "#comment" },
14
+ { "include": "#usage-header" },
15
+ { "include": "#program" },
16
+ { "include": "#string" },
17
+ { "include": "#repetition" },
18
+ { "include": "#argument" },
19
+ { "include": "#alternation" },
20
+ { "include": "#bracket-open" },
21
+ { "include": "#bracket-close" },
22
+ { "include": "#brace-open" },
23
+ { "include": "#brace-close" },
24
+ { "include": "#paren-open" },
25
+ { "include": "#paren-close" },
26
+ { "include": "#assignment" },
27
+ { "include": "#separator-comma" },
28
+ { "include": "#separator-colon" },
29
+ { "include": "#option-long" },
30
+ { "include": "#option-short" },
31
+ { "include": "#option-bare" },
32
+ { "include": "#sign" },
33
+ { "include": "#identifier" }
34
+ ]
35
+ },
36
+ "comment": {
37
+ "match": "^#.*$",
38
+ "name": "comment.line.number-sign.docopt"
39
+ },
40
+ "usage-header": {
41
+ "match": "^[ \\t]*(?:[Uu][Ss][Aa][Gg][Ee]:|SYNOPSIS)[ \\t]*$",
42
+ "name": "comment.line.usage.docopt"
43
+ },
44
+ "program": {
45
+ "match": "^[ \\t]*([_a-zA-Z][_a-zA-Z0-9]*)",
46
+ "captures": {
47
+ "1": { "name": "entity.name.function.docopt" }
48
+ }
49
+ },
50
+ "identifier": {
51
+ "match": "\\b[_a-zA-Z][_a-zA-Z0-9]*(?:[./][_a-zA-Z0-9]+)*",
52
+ "name": "variable.parameter.docopt"
53
+ },
54
+ "argument": {
55
+ "begin": "<",
56
+ "end": ">",
57
+ "name": "variable.parameter.docopt",
58
+ "beginCaptures": {
59
+ "0": { "name": "punctuation.definition.variable.begin.docopt" }
60
+ },
61
+ "endCaptures": {
62
+ "0": { "name": "punctuation.definition.variable.end.docopt" }
63
+ }
64
+ },
65
+ "string": {
66
+ "patterns": [
67
+ {
68
+ "name": "string.quoted.single.docopt",
69
+ "begin": "'",
70
+ "end": "'",
71
+ "patterns": [
72
+ {
73
+ "name": "constant.character.escape.docopt",
74
+ "match": "\\\\."
75
+ }
76
+ ]
77
+ },
78
+ {
79
+ "name": "string.quoted.double.docopt",
80
+ "begin": "\"",
81
+ "end": "\"",
82
+ "patterns": [
83
+ {
84
+ "name": "constant.character.escape.docopt",
85
+ "match": "\\\\."
86
+ }
87
+ ]
88
+ }
89
+ ]
90
+ },
91
+ "repetition": {
92
+ "match": "\\.\\.\\.",
93
+ "name": "keyword.operator.ellipsis.docopt"
94
+ },
95
+ "alternation": {
96
+ "match": "\\|",
97
+ "name": "keyword.operator.alternation.docopt"
98
+ },
99
+ "bracket-open": {
100
+ "match": "\\[",
101
+ "name": "punctuation.section.brackets.begin.docopt"
102
+ },
103
+ "bracket-close": {
104
+ "match": "\\]",
105
+ "name": "punctuation.section.brackets.end.docopt"
106
+ },
107
+ "brace-open": {
108
+ "match": "\\{",
109
+ "name": "punctuation.section.braces.begin.docopt"
110
+ },
111
+ "brace-close": {
112
+ "match": "\\}",
113
+ "name": "punctuation.section.braces.end.docopt"
114
+ },
115
+ "paren-open": {
116
+ "match": "\\(",
117
+ "name": "punctuation.section.parens.begin.docopt"
118
+ },
119
+ "paren-close": {
120
+ "match": "\\)",
121
+ "name": "punctuation.section.parens.end.docopt"
122
+ },
123
+ "assignment": {
124
+ "match": "=",
125
+ "name": "keyword.operator.assignment.docopt"
126
+ },
127
+ "separator-comma": {
128
+ "match": ",",
129
+ "name": "punctuation.separator.comma.docopt"
130
+ },
131
+ "separator-colon": {
132
+ "match": ":",
133
+ "name": "punctuation.separator.colon.docopt"
134
+ },
135
+ "option-long": {
136
+ "match": "(--)([_a-zA-Z][-_a-zA-Z0-9]*)(?:(=)([_a-zA-Z0-9][_a-zA-Z0-9]*(?:[./][_a-zA-Z0-9]+)*))?",
137
+ "captures": {
138
+ "1": { "name": "punctuation.definition.option.long.docopt" },
139
+ "2": { "name": "entity.name.tag.docopt" },
140
+ "3": { "name": "keyword.operator.assignment.docopt" },
141
+ "4": { "name": "variable.parameter.docopt" }
142
+ }
143
+ },
144
+ "option-short": {
145
+ "match": "([-+])([_a-zA-Z][_a-zA-Z0-9]*)",
146
+ "captures": {
147
+ "1": { "name": "punctuation.definition.option.short.docopt" },
148
+ "2": { "name": "entity.name.tag.docopt" }
149
+ }
150
+ },
151
+ "option-bare": {
152
+ "match": "--",
153
+ "name": "keyword.operator.docopt"
154
+ },
155
+ "sign": {
156
+ "match": "[-+]",
157
+ "name": "punctuation.definition.option.short.docopt"
158
+ }
159
+ }
160
+ }
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@carlwr/docopt-tmlanguage",
3
+ "version": "0.1.1",
4
+ "description": "TextMate grammar for docopt-style command synopsis notation",
5
+ "license": "MIT",
6
+ "author": "Carl Wernhoff",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/carlwr/docopt-tmlanguage.git"
10
+ },
11
+ "homepage": "https://github.com/carlwr/docopt-tmlanguage#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/carlwr/docopt-tmlanguage/issues"
14
+ },
15
+ "type": "module",
16
+ "files": [
17
+ "docopt.tmLanguage.json",
18
+ "LICENSE"
19
+ ],
20
+ "exports": {
21
+ ".": "./docopt.tmLanguage.json",
22
+ "./grammar.json": "./docopt.tmLanguage.json",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "keywords": [
26
+ "textmate",
27
+ "tmlanguage",
28
+ "grammar",
29
+ "syntax-highlighting",
30
+ "docopt",
31
+ "shiki"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "devDependencies": {
37
+ "@carlwr/textmate-validate": "^1.0.1",
38
+ "vscode-tmgrammar-test": "^0.1.3"
39
+ },
40
+ "scripts": {
41
+ "check": "textmate-validate -v ./docopt.tmLanguage.json",
42
+ "test": "vscode-tmgrammar-test -g ./docopt.tmLanguage.json 'tests/**/*.docopt'",
43
+ "qa": "npm run check && npm run test",
44
+ "version:patch": "npm version patch",
45
+ "version:minor": "npm version minor",
46
+ "version:major": "npm version major",
47
+ "preversion": "npm run qa",
48
+ "postversion": "git push --follow-tags",
49
+ "prepublishOnly": "npm run qa"
50
+ }
51
+ }