core: fix preparation-function signature in publish-doc and exclude dockerfiles

Also respect 80 chars per lines a various places
This commit is contained in:
syl20bnr 2017-01-12 23:19:53 -05:00
parent 796fcfaa53
commit c66f13b7cb
1 changed files with 33 additions and 22 deletions

View File

@ -32,8 +32,9 @@
(layers (-filter (lambda (p)
(eq 'layer (configuration-layer//directory-type p)))
all-subs))
(categories (-filter (lambda (p)
(eq 'category (configuration-layer//directory-type p)))
(categories (-filter
(lambda (p)
(eq 'category (configuration-layer//directory-type p)))
all-subs)))
(message "%S" layers)
(dolist (l layers)
@ -44,16 +45,16 @@
(insert (format "- [[file:%s][%s]]\n" target-path layer-name))))
(dolist (c categories)
(let* ((category-name (substring (file-name-nondirectory c) 1))
(pretty-name (or (cdr (assoc category-name spacemacs--category-names))
(s-capitalize (replace-regexp-in-string
"-" " " category-name)))))
(pretty-name
(or (cdr (assoc category-name spacemacs--category-names))
(s-capitalize (replace-regexp-in-string
"-" " " category-name)))))
(message "%S" category-name)
(unless (string= "distribution" category-name)
(insert (format "\n%s %s\n" level pretty-name))
(spacemacs//generate-layers-from-path c (concat level "*"))
)))))
(spacemacs//generate-layers-from-path c (concat level "*")))))))
(defun spacemacs//generate-layers-file ()
(defun spacemacs/generate-layers-file (project-plist)
"Generate the layers list file."
(interactive)
(with-temp-buffer
@ -76,7 +77,8 @@
(let* ((end-of-heading-pos (+ (length "Contents") heading-pos))
(beginning-of-heading (substring toc 0 end-of-heading-pos))
(rest-of-toc (substring toc end-of-heading-pos)))
(format "%s<a href=\"#\">Close</a>%s" beginning-of-heading rest-of-toc))
(format "%s<a href=\"#\">Close</a>%s"
beginning-of-heading rest-of-toc))
toc))
(car r)))
@ -85,8 +87,10 @@
(div-string "<div id=\"content\">")
(toc-string "<div id=\"toggle-sidebar\"><a href=\"#table-of-contents\"><h2>Table of Contents</h2></a></div>")
(has-toc (s-index-of "Table of Contents" content))
(beginning-of-content-div-pos (+ (length div-string) (s-index-of div-string content)))
(beginning-of-content (substring content 0 beginning-of-content-div-pos))
(beginning-of-content-div-pos (+ (length div-string)
(s-index-of div-string content)))
(beginning-of-content (substring content
0 beginning-of-content-div-pos))
(rest-of-content (substring content beginning-of-content-div-pos)))
(if (not (null has-toc))
(format "%s\n%s%s" beginning-of-content toc-string rest-of-content)
@ -100,7 +104,8 @@
(defun spacemacs//org-heading-annotate-custom-id ()
"Annotate headings with the indexes that GitHub uses for linking.
`org-html-publish-to-html' will use them instead of the default #orgheadline{N}.
This way the GitHub links and the http://spacemacs.org/ links will be compatible."
This way the GitHub links and the http://spacemacs.org/ links will be
compatible."
(progn (goto-char (point-min))
(goto-char (point-min))
(while (re-search-forward "^[\\*]+\s\\(.*\\).*$" nil t)
@ -116,14 +121,16 @@ This way the GitHub links and the http://spacemacs.org/ links will be compatible
toc-org-tags-regexp
""
heading))
;; Remove # prefix added by `toc-org-hrefify-gh'.
;; Remove # prefix added by
;; `toc-org-hrefify-gh'.
1))))))))
(defun spacemacs//reroot-links ()
"Find the links that start with https://github.com/syl20bnr/spacemacs/blob/
and end with .org{#an-optional-heading-link} (i.e the links between the local org files).
Change their root to http://spacemacs.org/ so the links will point at files located on the site.
For the file to file links to work properly the exported org files should be processed with
and end with .org{#an-optional-heading-link} (i.e the links between the local
org files). Change their root to http://spacemacs.org/ so the links will point
at files located on the site. For the file to file links to work properly the
exported org files should be processed with
the `spacemacs//org-heading-annotate-custom-id' function."
(let ((git-url-root-regexp
(concat "\\[\\[[\\s]*\\(https\\:\\/\\/github\\.com\\/syl20bnr"
@ -143,7 +150,8 @@ the `spacemacs//org-heading-annotate-custom-id' function."
"href=\""))
(head-css-extra-readtheorg-tail "css/readtheorg.css\" />\n"))
(progn (goto-char (point-min))
(delete-matching-lines "\\+HTML_HEAD_EXTRA\\:.*\\/css\\/readtheorg\\.css")
(delete-matching-lines
"\\+HTML_HEAD_EXTRA\\:.*\\/css\\/readtheorg\\.css")
(goto-char (point-min))
(if (search-forward "#+TITLE:" nil t nil)
(beginning-of-line 2)
@ -162,7 +170,8 @@ preprocessors for the exported .org files."
(let* ((filename (car (nthcdr 1 args)))
(visitingp (find-buffer-visiting filename)))
;; Temporary "unvisit" the visited org files.
(when visitingp (with-current-buffer visitingp (setq buffer-file-name nil)))
(when visitingp (with-current-buffer visitingp
(setq buffer-file-name nil)))
(with-temp-buffer
(save-match-data
(insert-file-contents filename t)
@ -173,8 +182,10 @@ preprocessors for the exported .org files."
(spacemacs//org-heading-annotate-custom-id)
(apply origfunc args)
(not-modified)))
;; Restore `buffer-file-name' for the buffers that previously visited the org files.
(when visitingp (with-current-buffer visitingp (setq buffer-file-name filename)))))))
;; Restore `buffer-file-name' for the buffers that previously visited
;; the org files.
(when visitingp (with-current-buffer visitingp
(setq buffer-file-name filename)))))))
(defun spacemacs/publish-doc ()
"Publish the documentation to doc/export/."
@ -227,8 +238,8 @@ preprocessors for the exported .org files."
:recursive t
:publishing-directory ,(concat publish-target "layers/")
:publishing-function org-html-publish-to-html
:preparation-function spacemacs//generate-layers-file
:exclude "local"
:preparation-function spacemacs/generate-layers-file
:exclude "local\\|dockerfiles"
:html-head ,header)
("spacemacs-doc-static"
:base-directory ,spacemacs-docs-directory