aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorStefan Kangas2022-09-14 16:22:59 +0200
committerStefan Kangas2022-09-14 18:42:10 +0200
commit5543aea1b2b8c68481ae0ce2bb501d8484ef7f7c (patch)
treee06082320fb787e77b482119af70219464b7408d /admin
parent23a91163ed13548c52c282c776f9cc6be308f3a1 (diff)
downloademacs-5543aea1b2b8c68481ae0ce2bb501d8484ef7f7c.tar.gz
emacs-5543aea1b2b8c68481ae0ce2bb501d8484ef7f7c.zip
Automate exporting etc/NEWS to HTML
* admin/admin.el (make-news-html-file): New function. * .gitignore: Ignore generated "etc/NEWS*.html" file.
Diffstat (limited to 'admin')
-rw-r--r--admin/admin.el130
1 files changed, 130 insertions, 0 deletions
diff --git a/admin/admin.el b/admin/admin.el
index 67cbf85a32a..12e6fcb7f8c 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -770,6 +770,136 @@ Optional argument TYPE is type of output (nil means all)."
770 (if (member type (list nil m)) 770 (if (member type (list nil m))
771 (make-manuals-dist--1 root m)))) 771 (make-manuals-dist--1 root m))))
772 772
773(defun make-news-html-file (root version)
774 "Convert the NEWS file into an HTML file."
775 (interactive (let ((root
776 (if noninteractive
777 (or (pop command-line-args-left)
778 default-directory)
779 (read-directory-name "Emacs root directory: "
780 source-directory nil t))))
781 (list root
782 (read-string "Version number: " emacs-version))))
783 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
784 (user-error "%s doesn't seem to be the root of an Emacs source tree" root))
785 (let* ((dir (make-temp-file "emacs-news-file" t))
786 (orig (expand-file-name "etc/NEWS" root))
787 (new (expand-file-name (format "NEWS.%s.org" version) dir))
788 (html-file (format "%s.html" (file-name-base new)))
789 (copyright-years (format-time-string "%Y")))
790 (unwind-protect
791 (progn
792 (copy-file orig new)
793 (find-file new)
794
795 ;; Find the copyright range:
796 (goto-char (point-min))
797 (re-search-forward "^Copyright (C) \\([0-9-]+\\) Free Software Foundation, Inc.")
798 (setq copyright-years (match-string 1))
799
800 ;; Get rid of some unnecessary stuff:
801 (replace-regexp-in-region "^---$" "" (point-min) (point-max))
802 (replace-regexp-in-region "^\\+\\+\\+$" "" (point-min) (point-max))
803 (dolist (str '(" \n"
804 "GNU Emacs NEWS -- history of user-visible changes."
805 "Temporary note:"
806 "+++ indicates that all relevant manuals in doc/ have been updated."
807 "--- means no change in the manuals is needed."
808 "When you add a new item, use the appropriate mark if you are sure it"
809 "applies, and please also update docstrings as needed."
810 "You can narrow news to a specific version by calling 'view-emacs-news'"
811 "with a prefix argument or by typing 'C-u C-h C-n'."))
812 (replace-string-in-region str "" (point-min) (point-max)))
813
814 ;; Use Org-mode markers for <code>.
815 (replace-regexp-in-region
816 ;; This could probably be improved quite a bit...
817 (rx "'" (group (+ (not (any "'\n")))) "'")
818 "~\\1~" (point-min) (point-max))
819
820 ;; Format Emacs Lisp.
821 (while (re-search-forward "^ " nil t)
822 (backward-paragraph)
823 (insert "\n#+begin_src emacs-lisp")
824 (forward-paragraph)
825 (insert "#+end_src\n"))
826
827 ;; Insert Org-mode export headers.
828 (goto-char (point-min))
829 (insert (format
830 "\
831#+title: GNU Emacs %s NEWS -- history of user-visible changes
832#+author:
833#+options: author:nil creator:nil toc:1 num:2 *:nil \\n:nil
834#+language: en
835#+HTML_LINK_HOME: https://www.gnu.org/software/emacs
836#+html_head_extra: <link rel=\"stylesheet\" type=\"text/css\" href=\"/mini.css\" media=\"handheld\" />
837#+html_head_extra: <link rel=\"stylesheet\" type=\"text/css\" href=\"/layout.min.css\" media=\"screen\" />
838#+html_head_extra: <link rel=\"stylesheet\" type=\"text/css\" href=\"/print.min.css\" media=\"print\" />
839
840#+BEGIN_EXPORT html
841<div style=\"float:right;margin-left:1em;padding:3px;border:0px solid;text-align:center\">
842<a href=\"/graphics/gnu-head.jpg\">
843<img src=\"/graphics/gnu-head-sm.jpg\" alt=\" [image of the head
844of a GNU] \" width=\"129\" height=\"122\"/>
845</a>
846</div>
847#+END_EXPORT\n\n"
848 version))
849 (org-mode)
850 (let ((org-html-postamble
851 (format
852 "
853<p>
854Return to the <a href=\"/software/emacs/emacs.html\">GNU Emacs home page</a>.
855</p>
856
857<div id=\"footer\">
858<div class=\"unprintable\">
859
860<p>
861Please send FSF &amp; GNU inquiries to
862<a href=\"mailto:gnu@gnu.org\">&lt;gnu@gnu.org&gt;</a>.
863There are also <a href=\"/contact/\">other ways to contact</a>
864the FSF.
865Broken links and other corrections or suggestions can be sent to
866<a href=\"mailto:bug-gnu-emacs@gnu.org\">&lt;bug-gnu-emacs@gnu.org&gt;</a>.
867</p>
868</div>
869
870<p>
871 Copyright &copy; %s Free Software Foundation, Inc.
872</p>
873
874<p>This page is licensed under
875a <a href=\"https://creativecommons.org/licenses/by-sa/4.0\">CC-BY-SA</a>
876license.</p>
877
878<!--#include virtual=\"/server/bottom-notes.html\" -->
879
880<p class=\"unprintable\">
881Updated:
882<!-- timestamp start -->
883$Date: %s $
884<!-- timestamp end -->
885</p>
886</div>
887</div>"
888 copyright-years
889 ;; e.g. "2022/09/13 09:13:13"
890 (format-time-string "%Y/%M/%y %H:%m:%S"))))
891 ;; Actually export.
892 (org-html-export-to-html)
893 ;; Kill the .org buffer.
894 (kill-buffer (current-buffer))
895 ;; Move file into place.
896 (let ((old (expand-file-name html-file dir))
897 (new (expand-file-name html-file (expand-file-name "etc" root))))
898 (delete-file new)
899 (copy-file old new)
900 (find-file new))))
901 (delete-directory dir t))))
902
773 903
774;; Stuff to check new `defcustom's got :version tags. 904;; Stuff to check new `defcustom's got :version tags.
775;; Adapted from check-declare.el. 905;; Adapted from check-declare.el.