Commit eba6c66e authored by Antoine Martin's avatar Antoine Martin
Browse files

Include README in Introduction if one is found

parent 87c26529
......@@ -57,3 +57,34 @@
(when makeinfo
(clean-or-create (from-quickref-dir "logs/makeinfo/"))
(clean-or-create (from-quickref-dir "website/"))))
(defun find-readme (release-name)
(let ((asd-file (ql-dist:base-directory
(ql-dist:find-release release-name))))
(car (directory (merge-pathnames "README.*"
asd-file)))))
(defun file-to-string (pathname)
(with-open-file (file pathname)
(alexandria:read-file-into-string file)))
(defmacro read-write-file ((pathname content stream) &body body)
`(let ((,content (file-to-string ,pathname)))
(with-open-file (,stream
,pathname
:direction :output
:if-exists :supersede)
,@body)))
(defun use-readme-intro (html-pathname readme-pathname)
(read-write-file (html-pathname html-text stream)
(write-sequence
(regex-replace
"\\<h2 class=\\\"chapter\\\"\\>1 Introduction\\<\\/h2\\>"
html-text
(format nil
"<h2 class=\"chapter\">1 Introduction</h2>
<pre>
~A
</pre>"
(file-to-string readme-pathname)))
stream)))
......@@ -21,5 +21,9 @@
:library cl-user::*qrmapper-object-name*
:texi-file (quickref:from-quickref-dir
(format nil "texis/~A.texi"
cl-user::*qrmapper-object-name*)))
cl-user::*qrmapper-object-name*))
:introduction (if (quickref:find-readme
cl-user::*qrmapper-object-name*)
""
nil))
(format t "FINISHED BUILDING PACKAGE ~A~%" primary-system))
(asdf:defsystem quickref
:author "Antoine Martin"
:depends-on (:quicklisp :alexandria :net.didierverna.declt)
:depends-on (:quicklisp :alexandria :net.didierverna.declt :cl-ppcre)
:serial t
:components ((:file "quickref")
(:file "qrmapper")
......
......@@ -5,6 +5,8 @@
(:import-from :sb-ext
:run-program
:native-namestring)
(:import-from :cl-ppcre
:regex-replace)
(:export :print-primary-systems
:get-primary-system-name
:from-quickref-dir
......
......@@ -98,26 +98,35 @@ The resulting file is written at ~/quickref/index.html"
(format file "</body>~%")))
(defun build-texi (texi)
(format t "Generating html file for ~A~%" (pathname-name texi))
(let ((out (with-output-to-string (out)
(sb-ext:run-program
*makeinfo-path*
(nconc
(list "--html" (namestring texi)
"-o" (namestring
(from-quickref-dir
(format nil "website/~A.html" (pathname-name texi))))
"--css-ref" "/document.css"
"-c" "TOP_NODE_UP_URL=/"
"--no-split")
(if *log-errors*
'("--force")
nil))
:output out))))
(when (not (string= out ""))
(if *log-errors*
(log-texi-error out texi)
(format t out)))))
(let ((texi-name (pathname-name texi)))
(format t "Generating html file for ~A" texi-name)
(let ((out (with-output-to-string (out)
(sb-ext:run-program
*makeinfo-path*
(nconc
(list "--html" (namestring texi)
"-o" (namestring
(from-quickref-dir
(format nil "website/~A.html" texi-name)))
"--css-ref" "/document.css"
"-c" "TOP_NODE_UP_URL=/"
"--no-split")
(if *log-errors*
'("--force")
nil))
:output out))))
(when (not (string= out ""))
(if *log-errors*
(log-texi-error out texi)
(format t out))))
;; Add README in Introduction if we find one
(let ((readme-path (find-readme texi-name)))
(when readme-path
(format t " with README")
(use-readme-intro
(from-quickref-dir (format nil "website/~A.html" texi-name))
readme-path))))
(format t "~%"))
(defun build-texis (&key (makeinfo-path *makeinfo-path*) (log-errors *log-errors*))
"Calls makeinfo on each .texi file, places the resulting html files in ~/quickref/"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment