refactor(file-templates): doom readme templates

Including readme template for categories.
This commit is contained in:
Henrik Lissner 2021-10-12 21:26:05 +02:00 committed by Henrik Lissner
parent df62fcba26
commit 0aad1399cc
7 changed files with 229 additions and 58 deletions

View file

@ -96,6 +96,14 @@ evil is loaded and enabled)."
(file-relative-name path doom-private-dir)) (file-relative-name path doom-private-dir))
((abbreviate-file-name path)))))) ((abbreviate-file-name path))))))
;;;###autoload
(defun +file-templates-module-for-path (&optional path)
"Generate a title for a doom module's readme at PATH."
(let ((m (doom-module-from-path (or path (buffer-file-name)))))
(if (eq (cdr m) 'README.org)
(symbol-name (car m))
(format "%s %s" (car m) (cdr m)))))
;; ;;
;;; Commands ;;; Commands
@ -133,3 +141,20 @@ for it. This is used for testing."
:key #'yas--template-key :test #'equal)) :key #'yas--template-key :test #'equal))
(message "Found %s" (cons pred plist)) (message "Found %s" (cons pred plist))
(message "Found rule, but can't find associated snippet: %s" (cons pred plist))))) (message "Found rule, but can't find associated snippet: %s" (cons pred plist)))))
;;
;;; Trigger functions
(defun +file-templates-insert-doom-docs-fn ()
"Expand one of Doom's README templates depending."
(+file-templates--expand
t :trigger
(let ((path (file-truename (buffer-file-name))))
(cond ((string-match-p "/modules/[^/]+/README\\.org$" path)
"__doom-category-readme")
((string-match-p "/modules/[^/]+/[^/]+/README\\.org$" path)
"__doom-readme")
((file-in-directory-p path doom-docs-dir)
"__doom-docs")
("__")))))

View file

@ -72,9 +72,8 @@ don't have a :trigger property in `+file-templates-alist'.")
("/shell\\.nix$" :trigger "__shell.nix") ("/shell\\.nix$" :trigger "__shell.nix")
(nix-mode) (nix-mode)
;; Org ;; Org
("/README\\.org$" (doom-docs-org-mode
:when +file-templates-in-emacs-dirs-p :trigger +file-templates-insert-doom-docs-fn
:trigger "__doom-readme"
:mode org-mode) :mode org-mode)
(org-journal-mode :ignore t) (org-journal-mode :ignore t)
(org-mode) (org-mode)

View file

@ -0,0 +1,12 @@
# -*- mode: snippet -*-
# name: Doom category readme
# --
← [[doom-module-index:][Back to module index]] ↖ [[doom-module-source:lang][Source]] ± [[doom-suggest-edit:][Suggest edits]] ? [[doom-help-modules:][Help]]
--------------------------------------------------------------------------------
#+TITLE: `(+file-templates-module-for-path)`
#+CREATED: `(format-time-string "%B %d, %Y")`
#+SINCE: `(car (split-string doom-version "-"))`
$0
* Description
Replace this with a description of what modules in this category are for,
including any important information (like load order constraints).

View file

@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: Doom documentation
# --
← [[doom-index:][Back to index]] ↖ [[doom-docs-source:faq.org][Source]] ± [[doom-suggest-edit:][Suggest edits]] ? [[doom-help:][Help]]
--------------------------------------------------------------------------------
#+TITLE: ${1:Title}
#+SUBTITLE: ${2:Subtitle}
$0

View file

@ -1,70 +1,196 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: Doom module readme # name: Doom module readme
# -- # --
#+TITLE: ${1:`(if (string-match "modules/\\([^/]+\\)/\\([^/]+\\)/.+" buffer-file-name) ← [[doom-module-index:][Back to module index]] ↙ [[doom-module-issues:::lang rust][Issues]] ↖ [[doom-module-source:lang/rust][Source]] ± [[doom-suggest-edit:][Suggest edits]] ? [[doom-help-modules:][Help]]
(format "%s/%s" --------------------------------------------------------------------------------
(match-string 1 buffer-file-name) #+TITLE: `(+file-templates-module-for-path)`
(match-string 2 buffer-file-name)) #+SUBTITLE: <A one-line quip about this module to display in init.example.el>
"")`} #+CREATED: `(format-time-string "%B %d, %Y")`
#+DATE: `(format (format-time-string "%B %%s, %Y") (string-to-number (format-time-string "%d")))` #+SINCE: `(car (split-string doom-version "-"))` (#COMMIT-OR-PR-REF)
#+SINCE: ${2:<replace with next tagged release version>}
#+STARTUP: inlineimages nofold
* Table of Contents :TOC_3:noexport: * Description :unfold:
$0Replace this with a short (1-2 sentence) description of what this module does.
This is displayed in the module index.
* Description Then a longer, multiple paragraph description goes here, which should explain
${3:# A summary of what this module does.} the purpose of the module and the features/technology(ies) it provides.
+ If possible, include a brief list of feature highlights here
+ Like code completion, syntax checking or available snippets
+ Include links to packages & external things where possible
** Maintainers ** Maintainers
+ @username_linked_to_gihub (Author) - [[doom-user:][@github_username]]
+ @username_linked_to_gihub - [[doom-user:][@github_username]]
+ @username_linked_to_gihub - [[doom-user:][@github_username]]
# If this module has no maintainers, then... [[doom-contrib-maintainer:][Become a maintainer?]]
This module has no dedicated maintainers.
** Module Flags # If a module has no maintainers and can't be casually maintained by Henrik
+ =+flag1= A short description of what this flag does and what it might need # alone, use:
when enabled. *This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]]
+ =+flag2= A short description of what this flag does and what it might need
when enabled. # Otherwise, use:
+ =+flag3= A short description of what this flag does and what it might need /This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]]
when enabled.
** Module flags
# Flags should be in alphanumerical order.
- +bar ::
A short description of what this flag does and what it might need when
enabled.
- +childframe ::
Display X in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html][child frame]] rather than an overlay or tooltip. *Requires GUI
Emacs.*
- +lsp ::
Enable LSP support for ~X-mode~. Requires [[doom-module:][:tools lsp]] and a
langserver (supports A, B, and C).
# If this module has no flags, then... # If this module has no flags, then...
This module provides no flags. /This module has no flags./
** Plugins # If this module has flags but you can't document them now, add a TODO to the
# A list of linked plugins # heading and use:
+ [[https://orgmode.org/][org-plus-contrib]] #+begin_quote
+ [[https://github.com/sabof/org-bullets][org-bullets]] 🔨 This module has flags, but they aren't documented yet. [[doom-contrib-module:][Document them?]]
+ [[https://github.com/TobiasZawada/org-yt][org-yt]] #+end_quote
+ [[https://github.com/sebastiencs/company-box][company-box]]* (=+childframe=)
+ =:lang crystal= ** Packages
+ [[https://github.com/brantou/ob-crystal][ob-crystal]] - [[doom-package:][org]]
+ =:lang go= - [[doom-package:][org-contrib]] if [[doom-module:][+contrib]]
+ [[https://github.com/pope/ob-go][ob-go]] - [[doom-package:][org-bullets]] unless [[doom-module:][+bullets]]
+ =+present= - if [[doom-module:][+present]]
+ [[https://github.com/anler/centered-window-mode][centered-window]] - [[doom-package:][centered-window]]
+ [[https://github.com/takaxp/org-tree-slide][org-tree-slide]] - [[doom-package:][org-tree-slide]]
+ [[https://gitlab.com/oer/org-re-reveal][org-re-reveal]] - [[doom-package:][org-re-reveal]]
# If this module installs no packages, then...
/This module doesn't install any packages./
# If this module installs packages, but you can't document them now, add a TODO
# to the heading and use:
#+begin_quote
🔨 This module installs packages, but they aren't documented yet. [[doom-contrib-module:][Document
them?]]
#+end_quote
** Hacks ** Hacks
# A list of internal modifications to included packages; omit if unneeded # Place a list of internal (and potentially unexpected) modifications to
# included packages:
- Fixed X which should help you do Y
- Advised Z to work harder, better, faster, stronger.
- Tricked the hobbitses into giving me the precious.
* Prerequisites # If there aren't any hacks, use:
This module has no prerequisites. /No hacks documented for this module./
* Features # If this module contains hacks, but you can't document them now, add a TODO to
# An in-depth list of features, how to use them, and their dependencies. # the heading and use:
#+begin_quote
🔨 This module's hacks haven't been documented yet. [[doom-contrib-module:][Document them?]]
#+end_quote
* Configuration ** TODO Changelog
# How to configure this module, including common problems and how to address them. # Do not edit this by hand. Your commits are your changelog. Commits that
# shouldn't show up should use the 'Amend: ...' trailer (see
# https://docs.doomemacs.org/-/git-conventions for details).
#
# ALSO: Version headings should be linked to the respective heading in
# docs/changelog.org.
** [[doom-release:v21.12.0][v21.12.0]] [2021-12-30]
*** [[doom-commit:a1b2c3d4][commit SUBJECT linked to github commit]]
commit BODY
*** [[doom-commit:a1b2c3d4][commit SUBJECT linked to github commit]]
commit BODY
*** [[doom-commit:a1b2c3d4][commit SUBJECT linked to github commit]]
commit BODY
# If no changelog is available, use:
# This section will be machine generated. Don't edit it by hand.
/This module does not have a changelog yet./
* Installation
# This section should describe, in-depth, how to set up this module and its
# dependencies, starting with this line:
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
# ...Then list its external requirements, if any.
This module requires:
- ...
- ...
- ...
# And finally, go into detail about how to install them.
# If there are no external requirements, use:
/This module has no external requirements./
# If there are prerequisites but you can't document them yet, add TODO to the
# heading and use:
#+begin_quote
🔨 /No installation steps have been documented./ [[doom-contrib-module:][Document them?]]
#+end_quote
* Usage
# Walk the user through how this module is used.
# If this is left empty, add TODO to the heading and use:
#+begin_quote
🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]]
#+end_quote
# If this section has incomplete content, add TODO to the heading and use:
#+begin_quote
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
#+end_quote
* TODO Configuration
# Walk the user through how to configure this module, including any variables it
# exposes or user-facing configuration API.
# If this is left empty, add TODO to the heading and use:
#+begin_quote
🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]]
#+end_quote
# If this section has incomplete content, add TODO to the heading and use:
#+begin_quote
🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
#+end_quote
* Troubleshooting * Troubleshooting
# Common issues and their solution, or places to look for help. # List common issues and any workarounds/solutions, or link to external resources.
$0 [[doom-report:][Report an issue?]]
** Common issue
Solution.
** Common issue
Solution.
** Common issue
Solution.
# If this is left empty, use:
/There are no known problems with this module./ [[doom-report:][Report one?]]
* Frequently asked questions
[[doom-suggest-faq:][Ask a question?]]
# This is for adoption, design, or niche questions. More general
# usage/configuration matters should be covered in the sections above.
** Question
Answer
** Question
Answer
** Question
Answer
# If no questions are available, use
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
* TODO Appendix
# A glossary of important major modes, minor modes, commands, functions, faces,
# and variables that this module exposes. It doesn't have to be exhaustive and
# should omit explanation/documentation.
# If this is left empty, add TODO to the heading and use:
#+begin_quote
🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]]
#+end_quote
# If this section has incomplete content, add TODO to the heading and use:
#+begin_quote
🔨 /This module's appendix is incomplete./ [[doom-contrib-module:][Write more?]]
#+end_quote

View file

@ -95,7 +95,7 @@ if it's callable, `apropos' otherwise."
(with-demoted-errors "%s" (with-demoted-errors "%s"
(re-search-forward (re-search-forward
(if (caddr module) (if (caddr module)
"\\* Module Flags$" "\\* Module flags$"
"\\* Description$")) "\\* Description$"))
(when (caddr module) (when (caddr module)
(re-search-forward (format "=\\%s=" (caddr module)) (re-search-forward (format "=\\%s=" (caddr module))

View file

@ -195,9 +195,9 @@ exist, and `org-link' otherwise."
(user-error "Can't find Doom module '%s'" link)))) (user-error "Can't find Doom module '%s'" link))))
(when flag (when flag
(goto-char (point-min)) (goto-char (point-min))
(and (re-search-forward "^\\*+ \\(?:TODO \\)?Module Flags") (and (re-search-forward "^\\*+ \\(?:TODO \\)?Module flags")
(re-search-forward (format "^\\s-*- %s :: " (re-search-forward (format "^\\s-*- \\+%s ::[ \n]"
(regexp-quote (symbol-name flag))) (substring (symbol-name flag) 1))
(save-excursion (org-get-next-sibling) (save-excursion (org-get-next-sibling)
(point))) (point)))
(recenter))))) (recenter)))))