Add the ability to build the docs from cubes docstrings

This commit is contained in:
Sameer Rahmani 2021-10-12 00:35:05 +01:00
rodzic f52425825a
commit db967c38f3
27 zmienionych plików z 265 dodań i 74 usunięć

5
.gitignore vendored
Wyświetl plik

@ -43,4 +43,7 @@ website/*~
#*#
emacs.d/
build/
build/
docs/site/orgs/cubes/
**/*/sitemap.inc

Wyświetl plik

@ -86,4 +86,4 @@ dummy-x:
Xephyr -br -ac -noreset -screen 800x600 :1
.PHONY: test-wm
test-wm:
DISPLAY=:1 FG42_WM=true FG42_V3=true fg42-wm
DISPLAY=:1 FG42_WM=true FG42_V3=true ./fg42-wm

Wyświetl plik

@ -98,6 +98,9 @@ PARAMS:
(cond
((string= command "docs")
(do-command
(require 'fpkg)
(fpkg/use dash)
(require 'fg42/build/docs)
(fg42/build-docs build-dir)))

Wyświetl plik

@ -35,6 +35,7 @@
(require 'cubes/irc)
(require 'cubes/terminal)
(require 'cubes/java)
(require 'cubes/python)
(require 'cubes/snippets)
(require 'cubes/org)
(require 'cubes/git)
@ -49,20 +50,28 @@
(t
:background "#bd93f9" :height 0.1 :box nil))))
(defvar global-font-size 14)
(defvar global-font-size 10)
(setq lsp-clients-clangd-executable "/home/lxsameer/usr/lib/llvm-13rc2/bin/clangd")
(defconst LLVM_DIR "/home/lxsameer/src/serene/llvm-project")
(defconst llvm-config-dir (concat LLVM_DIR "/llvm/utils/emacs/"))
(defconst mlir-config-dir (concat LLVM_DIR "/mlir/utils/emacs/"))
(add-hook 'c++-mode-hook (lambda ()
(load (concat llvm-config-dir "emacs.el"))
(load (concat llvm-config-dir "llvm-mode.el"))
(load (concat llvm-config-dir "tablegen-mode.el"))))
(autoload 'mlir-mode (concat mlir-config-dir "mlir-mode") "Code highlighting for MLIR" t)
(add-to-list 'auto-mode-alist '("\\.mlir\\'" . mlir-mode))
(autoload 'llvm-mode (concat llvm-config-dir "llvm-mode") "Code highlighting for LLVMIR" t)
(add-to-list 'auto-mode-alist '("\\.llvmir\\'" . llvm-mode))
(autoload 'tablegen-mode (concat llvm-config-dir "tablegen-mode") "Code highlighting for tablegen" t)
(add-to-list 'auto-mode-alist '("\\.td\\'" . tablegen-mode))
;; =========== FG42 stuff ===============================
;; (use-flags wm font-icons cursor-type
@ -74,6 +83,7 @@
(use-flags
(fg42/merge-with-default-flags
wm
python
golang
rcirc
vterm
@ -96,6 +106,7 @@
(use-flags
(fg42/merge-with-default-flags
wm
-python
-golang
rcirc
vterm
@ -122,6 +133,7 @@
(fg42/company-cube)
(fg42/lsp-cube)
(fg42/c++-cube)
(fg42/python-cube)
(fg42/yaml-cube)
(fg42/flycheck-cube)
(fg42/org-cube)
@ -148,5 +160,7 @@
;;(global-set-key (kbd "C-,") 'previous-line)
;;(global-set-key (kbd "C-.") 'next-line)
(set-face-attribute 'region nil :background "#888")
(provide '.fg42)
;;; .fg42.v3.el ends here

45
core/cubes/all.el Normal file
Wyświetl plik

@ -0,0 +1,45 @@
;;; AllCubes --- An index to use import all the cubes at once -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://gitlab.com/FG42/FG42
;; Version: 3.0.0
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;; Code:
(require 'fg42/flags)
(require 'cubes/editor)
(require 'cubes/elisp)
(require 'cubes/region-expansion)
(require 'cubes/wm)
(require 'cubes/modeline)
(require 'cubes/autocompletion)
(require 'cubes/golang)
(require 'cubes/project)
(require 'cubes/irc)
(require 'cubes/terminal)
(require 'cubes/java)
(require 'cubes/python)
(require 'cubes/snippets)
(require 'cubes/org)
(require 'cubes/git)
(require 'cubes/bookmark)
(require 'cubes/terraform)
(provide 'cubes/all)
;;; all.el ends here

Wyświetl plik

@ -25,7 +25,8 @@
(require 'fg42/cube)
(defcube fg42/flycheck-cube
(:docs "cubes/fg42/flycheck-cube.org"
"This cube adds the `flycheck' support to fg42."
(:title "Flycheck cube"
:flag flycheck)
(fpkg/use flycheck
:defer ()
@ -34,13 +35,15 @@
(defcube fg42/yaml-cube
(:docs "cubes/fg42/prog-cubes.org"
"Yaml Support"
(:title "Yaml Support"
:no-flag t)
(fpkg/use yaml-mode))
(defcube fg42/lsp-cube
(:docs "cubes/fg42/lsp-cube.org"
"LSP cube"
(:title "LSP cube"
:flag lsp)
(fpkg/use lsp-mode
@ -55,7 +58,8 @@
(add-hook 'lsp-mode-hook 'lsp-ui-mode)))
(defcube fg42/cmake-cube
(:docs "cubes/fg42/cpp-cube.org"
"Cmake cube"
(:title "CMake cube"
:flag-default t
:flag cmake)
@ -64,7 +68,8 @@
(defcube fg42/c++-cube
(:docs "cubes/fg42/cpp-cube.org"
"C++ cube"
(:title "C++ cube"
:no-flag t)
(fg42/cmake-cube)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
@ -78,7 +83,8 @@
(defcube fg42/company-cube
(:docs "cubes/fg42/company-cube.org"
"Auto complete using company mode"
(:title "Company cube"
:flag company)
(fpkg/use company

Wyświetl plik

@ -30,7 +30,8 @@
(defcube fg42/bookmark-cube
(:docs "cubes/fg42/bookmark-cube.org"
"bookmark cube"
(:title "cubes/fg42/bookmark-cube.org"
:flag bookmark
:flag-default t)

Wyświetl plik

@ -34,7 +34,8 @@
(defcube fg42/pinentry-cube
(:docs "cubes/fg42/pinentry-cube.org"
"Pinentry cube with setup the =pinentry= program to be used within FG42."
(:title "Pinentry cube"
:flag pinentry
:flag-default t)
(fpkg/use pinentry
@ -44,7 +45,8 @@
(pinentry-start))))
(defcube fg42/imenu-cube
(:docs "cubes/fg42/imenu-cube.org"
"Imenu support"
(:title "Imenu cube"
:flag imenu
:flag-default t)
(fpkg/use imenu-list
@ -53,7 +55,8 @@
(defcube fg42/exec-path-cube
(:docs "cubes/fg42/exec-path-cube.org"
"This cube fixes the =exec-path-from-shell= issue on MacOS."
(:title "Exec path cube"
:flag exec-path-from-shell
:flag-default t)
(fpkg/use exec-path-from-shell
@ -63,7 +66,8 @@
(defcube fg42/hl-cube
(:docs "cubes/fg42/hl-path-cube.org"
"This cube highlight the curret line."
(:title "Current line highlight cube"
:flag hl-line
:flag-default t)
(require 'hl-line)
@ -71,7 +75,8 @@
(defcube fg42/cursor-cube
(:docs "cubes/fg42/cursor-cube.org"
"This cube controls the shape of the cursor."
(:title "Cursor cube"
:flag cursor-type
:flag-default t)
(let ((ctype (or (plist-get fg42/cursor-cube-params :type) 'box))
@ -82,9 +87,9 @@
(set-default 'cursor-type ctype)
(set-cursor-color ccolor)))))
(defcube fg42/buffer-navigation-cube
(:docs "cubes/fg42/buffer-navigation-cube.org"
"This cube controls the different aspect of buffer navigation"
(:title "Buffer navigation cube"
:flag buffer-navigation
:flag-default t)
@ -93,7 +98,8 @@
(defcube fg42/window-navigation-cube
(:docs "cubes/fg42/window-navigation-cube.org"
"This cube controls the different aspect of buffer navigation"
(:title "Window navigation cube"
:flag window-navigation
:flag-default t)
@ -102,7 +108,8 @@
(defcube fg42/font-cube
(:docs "cubes/fg42/font-cube.org"
"This cube controls the font configuration of *FG42*"
(:title "Font Cube"
:no-flag t
:flag-default t)
@ -116,8 +123,11 @@
(set-face-attribute 'default t :font font)))
(defcube fg42/dracula-theme-cube
(:docs "cubes/fg42/dracula-theme-cube.org"
;TODO: Replace this cube with a `theme-cube'
(defcube fg42/dracula-theme-cubez
"Replace this with a theme cube"
(:title "Dracula theme"
:no-flag t)
(require 'fg42/themes)
@ -137,7 +147,8 @@
(defcube fg42/selectrum-cube
(:docs "cubes/fg42/editor-cube.org"
"This cube adds support for `selectrum' to FG42"
(:title "Selectrum cube"
:flag selectrum
:flag-default t)
(fpkg/use selectrum
@ -161,7 +172,8 @@
(defcube fg42/editor-cube
(:docs "cubes/fg42/editor-cube.org"
"This is a meta cube that sets up the basic functionalities of an Editor"
(:title "Editor cube"
:no-flag t)
(fpkg/use rainbow-delimiters

Wyświetl plik

@ -26,7 +26,8 @@
(defcube fg42/elisp-cube
(:docs "cubes/fg42/elisp-cube.org"
"Elisp cube"
(:title "cubes/fg42/elisp-cube.org"
:no-flag t)
(fpkg/use rainbow-delimiters

Wyświetl plik

@ -34,33 +34,34 @@
(defcube fg42/fm-cube
(:docs "cubes/fg42/fm-cube.org"
:flag fm
:flag-default t)
"file manager"
(:title "cubes/fg42/fm-cube.org"
:flag fm
:flag-default t)
;; Linux only
;; TODO: change this to support OS X
(setq dired-listing-switches "-lFaGh1v --group-directories-first")
;; Linux only
;; TODO: change this to support OS X
(setq dired-listing-switches "-lFaGh1v --group-directories-first")
;; Show directories first
(setq ls-lisp-dirs-first t)
;; Show directories first
(setq ls-lisp-dirs-first t)
(setq dired-recursive-copies 'always)
(setq dired-recursive-deletes 'always)
(setq dired-recursive-copies 'always)
(setq dired-recursive-deletes 'always)
(define-key dired-mode-map (kbd "E") 'fg42/dired-external-open)
(fpkg/use dired+)
(add-to-list 'dired-mode-hook
(lambda ()
(require 'dired-x)
(require 'dired-aux)))
(define-key dired-mode-map (kbd "E") 'fg42/dired-external-open)
(fpkg/use dired+)
(add-to-list 'dired-mode-hook
(lambda ()
(require 'dired-x)
(require 'dired-aux)))
(when-flag async
(dired-async-mode 1))
(when-flag async
(dired-async-mode 1))
(fpkg/use dired-narrow
:bind (:map dired-mode-map
("/" . dired-narrow))))
(fpkg/use dired-narrow
:bind (:map dired-mode-map
("/" . dired-narrow))))
(provide 'cubes/fm)

Wyświetl plik

@ -30,7 +30,8 @@
(defcube fg42/git-cube
(:docs "cubes/fg42/git-cube.org"
"Git cube"
(:title "cubes/fg42/git-cube.org"
:flag git
:flag-default t)

Wyświetl plik

@ -28,8 +28,8 @@
(autoload-cube 'fg42/initialize-golang "golang/core.el" "Initalize the go mode.")
(defcube fg42/golang-cube
(:docs "cubes/fg42/golang-cube.org"
:flag golang)
"Golang support cube for fg42."
(:title "Golang cube" :flag golang)
(fpkg/use go-mode
:defer t

Wyświetl plik

@ -26,7 +26,8 @@
(defcube fg42/rcirc-cube
(:docs "cubes/fg42/rcirc-cube.org"
"IRC cube"
(:title "cubes/fg42/rcirc-cube.org"
:flag rcirc)
(autoload-cube 'fg42/rcirc-connect "irc/core.el" "Connect to IRC via RCIRC." t)
(defun fg42/connect-to-irc ()

Wyświetl plik

@ -26,7 +26,8 @@
(defcube fg42/gradle-cube
(:docs "cubes/fg42/java-cube.org"
"Gradle support"
(:title "cubes/fg42/java-cube.org"
:flag gradle
:flag-default t)
@ -41,7 +42,8 @@
(defcube fg42/java-cube
(:docs "cubes/fg42/java-cube.org"
"Java cube"
(:title "cubes/fg42/java-cube.org"
:flag java
:flag-default t)

Wyświetl plik

@ -26,7 +26,8 @@
;; TODO: Break this into two cubes
(defcube fg42/modeline-cube
(:docs "cubes/fg42/modeline-cube.org"
"Modeline cube"
(:title "cubes/fg42/modeline-cube.org"
:flag smart-mode-line
:flag-default t)

Wyświetl plik

@ -29,7 +29,8 @@
(require 'fg42/cube)
(defcube fg42/org-cube
(:docs "cubes/fg42/org-cube.org"
"Org cube"
(:title "cubes/fg42/org-cube.org"
:flag org
:flag-default t)

Wyświetl plik

@ -27,7 +27,8 @@
(defcube fg42/projectile-cube
(:docs "cubes/fg42/projectile-cube.org"
"Projectile Cube"
(:title "cubes/fg42/projectile-cube.org"
:flag projectile
:flag-default t)

80
core/cubes/python.el Normal file
Wyświetl plik

@ -0,0 +1,80 @@
;;; PythonCubes --- The Python cubes for FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://gitlab.com/FG42/FG42
;; Version: 3.0.0
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;; Code:
(require 'fpkg)
(require 'fg42/cube)
(require 'fg42/utils)
(defun fg42/py-workon-project-venv ()
"Call pyenv-workon with the current projectile project name.
This will return the full path of the associated virtual
environment found in $WORKON_HOME, or nil if the environment does
not exist."
(require 'pyenv)
(let ((pname (projectile-project-name)))
(pyvenv-workon pname)
(if (file-directory-p pyvenv-virtual-env)
pyvenv-virtual-env
(pyvenv-deactivate))))
(defun fg42/py-auto-lsp ()
"Turn on lsp mode in a Python project with some automated logic.
Try to automatically determine which pyenv virtual environment to
activate based on the project name, using
`dd/py-workon-project-venv'. If successful, call `lsp'. If we
cannot determine the virtualenv automatically, first call the
interactive `pyvenv-workon' function before `lsp'"
(interactive)
(let ((pvenv (fg42/py-workon-project-venv)))
(if pvenv
(lsp)
(progn
(call-interactively #'pyvenv-workon)
(lsp)))))
(defcube fg42/python-cube
"Python support cube."
(:title "Python cube"
:flag python)
(fpkg/use pyvenv
:defer t
:config
(setenv "WORKON_HOME" "~/.pyenv/versions"))
(when-flag lsp
(with-eval-after-load "lsp"
(lsp-register-custom-settings
'(("pyls.plugins.pyls_mypy.enabled" t t)
("pyls.plugins.flake8.enabled" t t)
("pyls.plugins.pyls_mypy.live_mode" nil t)
("pyls.plugins.pyls_black.enabled" t t)
("pyls.plugins.pyls_isort.enabled" t t)))
(add-hook 'python-mode #'fg42/py-auto-lsp))))
(provide 'cubes/python)
;;; python.el ends here

Wyświetl plik

@ -26,7 +26,8 @@
(defcube fg42/region-expansion-cube
(:docs "cubes/fg42/region-expansion.org")
"RE cube"
(:title "cubes/fg42/region-expansion.org")
(fpkg/use expand-region
:bind ("C-=" . er/expand-region)))

Wyświetl plik

@ -25,7 +25,8 @@
(require 'fg42/cube)
(defcube fg42/yasnippet-cube
(:docs "cubes/fg42/yasnippet-cube.org"
"Yasnippet cube"
(:title "cubes/fg42/yasnippet-cube.org"
:flag yasnippet
:flag-default t)

Wyświetl plik

@ -25,7 +25,8 @@
(require 'fg42/cube)
(defcube fg42/vterm-cube
(:docs "cubes/fg42/vterm-cube.org"
"Vterm cube"
(:title "cubes/fg42/vterm-cube.org"
:flag vterm)
(let ((_shell (or (plist-get fg42/vterm-cube-params :shell)
(getenv "SHELL"))))

Wyświetl plik

@ -30,7 +30,8 @@
(defcube fg42/terraform-cube
(:docs "cubes/fg42/terraform-cube.org"
"terraform cube"
(:title "cubes/fg42/terraform-cube.org"
:flag terraform
:flag-default t)

Wyświetl plik

@ -40,8 +40,9 @@
(defcube fg42/wm-cube
(:docs "cubes/fg42/wm-cube.org"
:no-flag t)
"This cube will setup *FG42* to act as a window manager."
(:title "Window manager cube"
:no-flag t)
(if-flag wm
(when-wm

Wyświetl plik

@ -29,16 +29,24 @@
(require 'fg42/utils)
(defmacro defcube (cube-name props &rest body)
"Define a cube with the given CUBE-NAME, a list of PROPS and a BODY."
(declare (indent defun))
(defvar fg42/available-cubes '()
"A list of all the registered cubes.")
(defmacro defcube (cube-name docs props &rest body)
"Define a cube with the given CUBE-NAME, a list of PROPS, DOCS and a BODY."
(declare (indent defun) (doc-string 2))
;; Make sure that props is a plist and contains the `:docs' key
;; TODO: Maybe use `cl-check-type' here
(when (not (plist-get props :docs))
(error "Missing docs key for '%s' cube" cube-name))
(when (not (stringp docs))
(error "Missing docstring for '%s' cube" cube-name))
(let ((cube-name-internal (intern (format "%s-internal" cube-name)))
(when (not (plist-get props :title))
(error "Missing :titel key for '%s' cube" cube-name))
(let ((complete-props (plist-put props :docs docs))
(cube-name-internal (intern (format "%s-internal" cube-name)))
(params-var (intern (format "%s-params" cube-name)))
(active-var (intern (format "%s-active-p" cube-name)))
(pre-lang-server-up-hook (intern (format "%s-pre-lang-server-up-hook" cube-name)))
@ -56,6 +64,8 @@
(flag-conflict (plist-get props :conflicts-with))
(no-flag? (or (plist-get props :no-flag) ())))
(add-to-list 'fg42/available-cubes cube-name)
`(progn
;; Create a new flag for each cube to control the cubes systemwide.
@ -134,7 +144,10 @@
;; Otherwise check for the flag to be active
(if-flag ,flag-var
(,cube-name-internal params)
(message "The flag for '%s' cube is disabled. Skiping." ,(symbol-name cube-name))))))))
(message "The flag for '%s' cube is disabled. Skiping." ,(symbol-name cube-name)))))
;; Set the symbol-plist of the cube-name to its props
(setplist ',cube-name ',complete-props))))
(provide 'fg42/cube)

Wyświetl plik

@ -37,7 +37,7 @@ On the first level, I should feel comfortable with it.
or other maintenance jobs
* Tasks
** TODO =fpkg/use= doesn't work with =:init=
** TODO Add a =:default= key to the cube indicating whether it should be enabled by default or not
** TODO Reformat the modeline
** TODO Create a macro similar to =with-ability= to run a block of code only if the given cube was active

Wyświetl plik

@ -1,6 +0,0 @@
#+TITLE: FG42, The ultimate editor for true believers
- [[file:categories/nil.org][<<<title>>>]]
- [[file:tags/index.org][Tags]]
- [[file:categories/index.org][Categories]]
- [[file:index.org][The little nest of mine]]

Wyświetl plik

@ -0,0 +1,6 @@
#+SETUPFILE: ../../../config.org
#+OPTIONS: toc:nil
#+TITLE: <<<:title>>>
#+PAGE: true
<<<:docs>>>