Skip to content

Commit 84daead

Browse files
committed
docs: add more to mode help text
1 parent be09aed commit 84daead

File tree

2 files changed

+93
-23
lines changed

2 files changed

+93
-23
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,20 @@ dependency tree and the validation tool.
113113
usual `C-u` binding.
114114
* The resulting tree view can be refreshed using the common binding of `g` and quit
115115
with `q`.
116+
117+
### Dependency Graph
118+
119+
If running under a `window-sytem` it is also possible to display the current
120+
buffer's dependencies as a directed graph. The tool will generate an SVG and
121+
display in a read-only window.
122+
123+
* Command `sdml-mode-current-buffer-dependency-graph` has the default binding `C-c
124+
C-s M-t`.
116125

117126
### Full Validation
118127

119128
* Command `sdml-mode-validate-current-buffer` has the default binding `C-c C-s v`.
120-
* Command `sdml-mode-validate` has the default binding `C-c C-s V`.
129+
* Command `sdml-mode-validate` has the default binding `C-c C-s M-v`.
121130
* The variable `sdml-mode-validation-level` denotes the level of messages produced
122131
by the validator, with a default of `warnings`.
123132
* The output uses the standard `compilation-mode` with all the common bindings are
@@ -148,14 +157,21 @@ cursor position.
148157
Note that for annotation properties with language string values the skeletons
149158
will add the value of the Emacs variable `locale-language` as the language tag.
150159

160+
## Prettify Symbol
161+
162+
The variable `sdml-mode-prettify-symbols-alist` specifies a set of symbols that
163+
may visually replace certain keywords or multi-character symbols in SDML source.
164+
For example the characters `"->"` may be replaced by the Unicode character ``
165+
or the keyword `"forall"` replaced with the Unicode ``.
166+
151167
### Default Key Bindings
152168

153169
* `C-c C-s d` -- open the tree-sitter debug view
154170
* `C-c C-s q` -- open the tree-sitter query builder
155171
* `C-c C-s t` -- open a dependency tree view for the current buffer
156172
* `C-c C-s v` -- run the validator, on the current buffer, and show the results in
157173
a compilation window
158-
* `C-c C-s V` -- run the validator, on a specified file, and show the results in
174+
* `C-c C-s M-v` -- run the validator, on a specified file, and show the results in
159175
a compilation window
160176
* `C-c C-s T` -- run u-ctags for the current project
161177

sdml-mode.el

Lines changed: 75 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
;; by `sdml-mode' and when typing one of the abbreviations below type space to
6767
;; expand.
6868
;;
69-
;; Typing `d t SPC' will prompt for a name and expand into the SDML declaration
69+
;; Typing `d t SPCA' will prompt for a name and expand into the SDML declaration
7070
;; `datatype MyName ← opaque _' where the underscore character represents the new
7171
;; cursor position.
7272
;;
@@ -92,7 +92,7 @@
9292
;;
9393
;; `(add-hook 'after-save-hook 'sdml-validate-current-buffer)'
9494
;;
95-
;; `sdml-mode-current-buffer-dependencies' (\\[sdml-mode-current-buffer-dependencies])
95+
;; `sdml-mode-current-buffer-dependency-tree' (\\[sdml-mode-current-buffer-dependency-tree])
9696
;; to display the dependencies of the curtent buffer's module.
9797
;;
9898

@@ -132,7 +132,7 @@
132132

133133
(defcustom sdml-mode-prettify-symbols-alist
134134
'(("->" . ?→) ("<-" . ?←) ("forall" ?∀) ("exists" ?∃) ("in" ?∈) (":=" ?≔))
135-
"An alist of symbol prettifications used for `prettify-symbols-alist'."
135+
"An alist of symbol replacements used for `prettify-symbols-alist'."
136136
:tag "Symbol mapping for prettify"
137137
:type '(repeat (cons string character))
138138
:group 'sdml)
@@ -154,7 +154,7 @@
154154
;; --------------------------------------------------------------------------
155155

156156
(defun sdml-mode--tree-sitter-setup (&optional dylib-file)
157-
"Load and connect the parser library in DYLIB-FILE.
157+
"Internal: Load and connect the parser library in DYLIB-FILE.
158158
159159
Load the dynamic library, either with the explicit path
160160
in DYLIB-FILE, or by searching the path in `tree-sitter-load-path'.
@@ -189,48 +189,92 @@ platform-specific extension in `tree-sitter-load-suffixes'."
189189
?\n))
190190

191191
(defun sdml-mode--command-setup ()
192-
"Setup buffer commands."
192+
"Internal: Setup buffer commands."
193193
(add-hook 'compilation-filter-hook 'ansi-color-compilation-filter)
194194
(setq-local ansi-color-for-compilation-mode t)
195195
(add-to-list 'compilation-error-regexp-alist-alist
196196
`(sdml ,sdml-mode-validation-error-regexp 5 6 7 (2 . 3)))
197197
(add-to-list 'compilation-error-regexp-alist 'sdml))
198198

199-
(defun sdml-mode-validate-file (file-name)
200-
"Validate FILE-NAME using the `compile' command."
201-
(interactive "fSDML File name: " sdml-mode)
199+
(defun sdml-mode--exec-validator (file-name)
200+
"Internal: execute the command-line validator for FILE-NAME."
202201
(let ((cmd-line (sdml-mode-cli-make-command
203202
"validate"
204203
(sdml-mode-cli-make-arg 'level sdml-mode-validation-level)
205204
(sdml-mode-cli-make-arg 'input file-name))))
206205
(when cmd-line
207206
(compile cmd-line))))
208207

208+
(defun sdml-mode-validate-file (file-name)
209+
"Validate FILE-NAME using the `compile' command.
210+
211+
This command executes the SDML command-line tool's validation
212+
tool, on the file FILE-NAME, using the value of
213+
`sdml-mode-validation-level' to determine the level of messages
214+
output. The command uses the `compile' function and the resulting
215+
window supports error navigation and source highlighting as
216+
usual."
217+
(interactive "fSDML File name: ")
218+
(sdml-mode--exec-validator file-name))
219+
209220
(defun sdml-mode-validate-current-buffer ()
210-
"Validate the current buffer using the `compile' command."
221+
"Validate the current buffer using the `compile' command.
222+
223+
This command executes the SDML command-line tool's validation
224+
tool, on the current buffer's underlying file, using the value of
225+
`sdml-mode-validation-level' to determine the level of messages
226+
output. The command uses the `compile' function and the resulting
227+
window supports error navigation and source highlighting as
228+
usual."
211229
(interactive nil sdml-mode)
212-
(let ((cmd-line (sdml-mode-cli-make-command
213-
"validate"
214-
(sdml-mode-cli-make-arg 'level sdml-mode-validation-level)
215-
'current-buffer)))
216-
(when cmd-line
217-
(compile cmd-line))))
230+
(sdml-mode--exec-validator (buffer-file-name)))
218231

219232

220233
;; --------------------------------------------------------------------------
221234
;; Buffer Commands  Dependencies
222235
;; --------------------------------------------------------------------------
223236

237+
238+
(defun sdml-mode-current-buffer-dependency-graph ()
239+
"Show full dependency graph in SVG of the current buffer.
240+
241+
This command generates an SVG representing the current buffer's
242+
dependencies as a directed graph. The command uses the SDML
243+
command-line tool to generate a temporary file which is then
244+
opened in a new window. The resulting image window may be dismissed
245+
using the key `q'."
246+
(interactive nil sdml-mode)
247+
(cond
248+
(window-system
249+
(let* ((output-file-name (concat (make-temp-file "sdml-mode") ".svg"))
250+
(cmd-line (sdml-mode-cli-make-command
251+
"deps"
252+
(sdml-mode-cli-make-arg 'output output-file-name)
253+
(sdml-mode-cli-make-arg 'output-format 'graph)
254+
(sdml-mode-cli-make-arg 'depth 0)
255+
'current-buffer)))
256+
(when cmd-line
257+
(sdml-mode-cli-run-command cmd-line)
258+
(find-file-other-window output-file-name))))
259+
(t (message "Command only available if window-system is set"))))
260+
224261
(defun sdml-mode-current-buffer-dependency-tree (depth)
225-
"Dependency of the current buffer, to a max DEPTH."
262+
"Show the dependency tree of the current buffer, to a max DEPTH.
263+
264+
This command generates a textual tree representing the current
265+
buffer's dependencies. The command uses the SDML command-line
266+
tool to generate the tree, using DEPTH to denote how many levels
267+
of dependencies to display. The resulting window may be dismissed
268+
using the key `q', and it's content may be refreshed with the key
269+
`g'."
226270
(interactive "nMax depth of tree (0=all): " sdml-mode)
227-
(when (derived-mode-p 'sdml-mode)
228-
(let ((cmd-line (sdml-mode-cli-make-command
271+
(let ((cmd-line (sdml-mode-cli-make-command
229272
"deps"
273+
(sdml-mode-cli-make-arg 'output-format 'tree)
230274
(sdml-mode-cli-make-arg 'depth depth)
231275
'current-buffer)))
232276
(when cmd-line
233-
(sdml-mode-cli-run-command cmd-line "*SDML Dependencies*" nil t)))))
277+
(sdml-mode-cli-run-command cmd-line "*SDML Dependencies*" nil t))))
234278

235279

236280
;; --------------------------------------------------------------------------
@@ -242,8 +286,9 @@ platform-specific extension in `tree-sitter-load-suffixes'."
242286
(define-key map (kbd "C-c C-s d") 'tree-sitter-debug-mode)
243287
(define-key map (kbd "C-c C-s q") 'tree-sitter-query-builder)
244288
(define-key map (kbd "C-c C-s v") 'sdml-mode-validate-current-buffer)
245-
(define-key map (kbd "C-c C-s V") 'sdml-mode-validate-file)
289+
(define-key map (kbd "C-c C-s M-v") 'sdml-mode-validate-file)
246290
(define-key map (kbd "C-c C-s t") 'sdml-mode-current-buffer-dependency-tree)
291+
(define-key map (kbd "C-c C-s M-t") 'sdml-mode-current-buffer-dependency-graph)
247292
map)
248293
"Keymap for SDML major mode.")
249294

@@ -267,7 +312,16 @@ platform-specific extension in `tree-sitter-load-suffixes'."
267312
sdml-mode
268313
prog-mode
269314
"SDML"
270-
"Major mode for editing SDML files.
315+
"A major mode for editing SDML (Simple Domain Modeling Language) files.
316+
317+
This major mode will, by default, enable the following minor modes:
318+
319+
- `abbrev-mode'
320+
- `prettify-symbols-mode' (see `sdml-mode-prettify-symbols-alist')
321+
- `tree-sitter-mode'
322+
- `sdml-mode-hl-mode'
323+
- `sdml-mode-indent-mode'
324+
- `sdml-mode-ctags-mode'
271325
272326
Key bindings:
273327
\\{sdml-mode-map}"

0 commit comments

Comments
 (0)