Add category check ignore list to the doc build processs

This commit is contained in:
Sameer Rahmani 2022-07-04 15:33:14 +01:00
parent c47738ce86
commit 4aec122767
3 changed files with 50 additions and 36 deletions

View File

@ -29,12 +29,14 @@
(setq debug-on-error t) (setq debug-on-error t)
(defconst fg42/CORE_DIR (concat (getenv "HOME") "/.fg42/core")) (setenv "FG42_HOME" (concat (getenv "HOME") "/.fg42/"))
(defconst fg42/CORE_DIR (concat (getenv "FG42_HOME") "core"))
(setq user-emacs-directory (concat (getenv "FG42_HOME") "emacs.d"))
(setq user-emacs-directory (concat (getenv "HOME") "/.fg42/emacs.d"))
(add-to-list 'load-path fg42/CORE_DIR) (add-to-list 'load-path fg42/CORE_DIR)
(require 'fg42/build/core) (require 'fg42/build/core)
(require 'fg42/build/utils)
(defvar FG42-VERSION "3.0.0-snapshot" (defvar FG42-VERSION "3.0.0-snapshot"
"The version number of the current build of FG42.") "The version number of the current build of FG42.")
@ -54,12 +56,6 @@ PARAMS:
") ")
(defproject FG42
project-root (nth 2 command-line-args-left)
docs-actions '(fg42/build-prepare-docs))
(defun print-help (command) (defun print-help (command)
"Print out a usage instructions and print out the invalid msg for COMMAND." "Print out a usage instructions and print out the invalid msg for COMMAND."
(when command (when command
@ -67,18 +63,15 @@ PARAMS:
(message build/usage)) (message build/usage))
(defmacro do-command (&rest body) (defproject FG42
"Run the BODY after loading FG42." project-root (nth 2 command-line-args-left)
`(progn docs-actions '(fg42/build-prepare-docs))
(require 'fg42)
(fg42/before-initialize)
,@body))
(defun main () (defun main ()
"The entry point to the build script." "The entry point to the build script."
(message (version)) (message (fg42/version))
(message "\nFG42 Build tool v%s\n\n" FG42-VERSION) (message "\nFG42 Build tool v%s\n\n" (fg42/version))
;; UTF-8 as default encoding ;; UTF-8 as default encoding
(prefer-coding-system 'utf-8) (prefer-coding-system 'utf-8)

View File

@ -50,6 +50,12 @@ project root.")
(defvar fg42/build-prod-base-url "https://fg42.org" (defvar fg42/build-prod-base-url "https://fg42.org"
"The base url to use with the docs for production.") "The base url to use with the docs for production.")
(defvar fg42/build-docs-pages-dir "/pages"
"Where to find the pages (relative to docs dir)")
(defvar fg42/build-docs-ignore-category-check nil
"A list of files that should be ignored by category/tag checks")
(defvar fg42/build-docs-actions nil (defvar fg42/build-docs-actions nil
"Set of actions to run before building the "Set of actions to run before building the
main docs.") main docs.")
@ -132,5 +138,13 @@ and write it to DEST."
(replace-in-buffer (format "<<<%s>>>" (car pair)) (cdr pair))))) (replace-in-buffer (format "<<<%s>>>" (car pair)) (cdr pair)))))
(defmacro do-command (&rest body)
"Run the BODY after loading FG42."
`(progn
(require 'fg42)
(fg42/before-initialize)
,@body))
(provide 'fg42/build/core) (provide 'fg42/build/core)
;;; core.el ends here ;;; core.el ends here

View File

@ -51,13 +51,14 @@
(defun fg42/build-docs-copy-base (build-dir) (defun fg42/build-docs-copy-base (build-dir)
"Copy the base structure of the website to the BUILD-DIR." "Copy the base structure of the website to the BUILD-DIR."
(copy-directory (from-docs "/pages") (copy-directory (from-docs fg42/build-docs-pages-dir)
(expand-file-name "site/pages" build-dir) nil t)) (expand-file-name (format "site/%s" fg42/build-docs-pages-dir)
build-dir)
nil t))
(defun fg42/build-prepare-docs (build-dir host) (defun fg42/build-prepare-docs (build-dir host)
"Prepare the documents and the website in the given BUILD-DIR." "Prepare the documents and the website in the given BUILD-DIR."
(fg42/build-docs-copy-base build-dir)
;; Build the org files for each cube ;; Build the org files for each cube
(message "Processing the docs for all the cubes") (message "Processing the docs for all the cubes")
@ -162,22 +163,25 @@ Not pages."
(seq-reduce (seq-reduce
;; all-cats is in (cats . cat->files) form ;; all-cats is in (cats . cat->files) form
(lambda (all-cats file) (lambda (all-cats file)
(let ((is-page? (string= (get-file-global-props file "PAGE") "true")) (if (not (member (file-relative-name file org-directory)
(cat (get-file-global-props file "CATEGORY")) fg42/build-docs-ignore-category-check))
(cat-list (car all-cats)) (let ((is-page? (string= (get-file-global-props file "PAGE") "true"))
(cat->file (cdr all-cats))) (cat (get-file-global-props file "CATEGORY"))
(cat-list (car all-cats))
(cat->file (cdr all-cats)))
(if (not is-page?) (if (not is-page?)
(cons (cons
;; Category list ;; Category list
(if (member cat cat-list) cat-list (sort (cons cat cat-list) 'string<)) (if (member cat cat-list) cat-list (sort (cons cat cat-list) 'string<))
;; cat->file ;; cat->file
(cons (cons cat (cons (cons cat
;; Current value of the the given cat (all the files ;; Current value of the the given cat (all the files
;; under that category) ;; under that category)
(append (list file) (cdr (assoc cat cat->file)))) (append (list file) (cdr (assoc cat cat->file))))
cat->file)) cat->file))
all-cats))) all-cats))
all-cats))
(all-org-files) (all-org-files)
'())) '()))
@ -244,10 +248,11 @@ Not pages."
(when (null tag) (when (null tag)
(message "[Error]: The following files are missig a category: %s" (message "[Error]: The following files are missig a category: %s"
(mapconcat (mapconcat
(lambda (x) (format " %s\n" x)) (lambda (x) (format " %s" x))
(sort (sort
(mapcar #'pair-file-with-date files) (mapcar #'pair-file-with-date files)
(lambda (x y) (> (car x) (car y)))))) (lambda (x y) (> (car x) (car y))))
"\n"))
(error "The above list of files are missing a category")) (error "The above list of files are missing a category"))
(copy-template (copy-template
@ -276,6 +281,8 @@ Not pages."
(stage1-dir (expand-file-name "site" build-dir)) (stage1-dir (expand-file-name "site" build-dir))
(final-dir (expand-file-name "site-build" build-dir))) (final-dir (expand-file-name "site-build" build-dir)))
(fg42/build-docs-copy-base build-dir)
;; Apply all the actions ;; Apply all the actions
(mapcar (lambda (f) (mapcar (lambda (f)
(funcall f build-dir base-url)) (funcall f build-dir base-url))