Commit 973cc8a6 authored by Antoine Martin's avatar Antoine Martin
Browse files

Split into two files

parent 9202113a
......@@ -2,4 +2,5 @@
:author "Antoine Martin"
:depends-on (:quicklisp :alexandria :split-sequence)
:serial t
:components ((:file "quickref")))
:components ((:file "quickref")
(:file "website")))
......@@ -43,114 +43,3 @@
(defun print-primary-systems ()
(dolist (release (ql-dist:provided-releases t))
(print (get-primary-system-name (ql-dist:name release)))))
(defun get-columns-length (size)
(if (equal size 1) (values 1 0 0)
(multiple-value-bind (split remainder) (floor size 3)
(case remainder
(0 (values split split split))
(1 (values (+ split 1) (+ split 1) (- split 1)))
(2 (values (+ split 1) (+ split 1) split))))))
(defun build-cell (s)
(format nil "<td></td><td><a href=\"~A\">~A</a></td>" s s))
(defun print-columns (l size file)
(multiple-value-bind (lfirst lsecond lthird)
(get-columns-length size)
(do ((n 0 (+ n 1))
(f l (cdr f))
(s (nthcdr lfirst l) (cdr s))
(th (nthcdr (+ lfirst lsecond) l) (cdr th)))
((= n lfirst) nil)
(if (>= n lsecond)
(format file
"<tr>~A</tr>~%"
(build-cell (car f)))
(if (>= n lthird)
(format file
"<tr>~A~A</tr>~%"
(build-cell (car f)) (build-cell (car s)))
(format file
"<tr>~A~A~A</tr>~%"
(build-cell (car f)) (build-cell (car s)) (build-cell (car th))))))))
(defun get-directory-list (path)
(loop for dir in (directory path)
collect (car (last (pathname-directory dir)))))
(defun get-first-letter (sequence)
(subseq sequence 0 1))
(defun is-number (string)
(let ((chara (char string 0)))
(and (>= (char-code chara) (char-code #\0))
(<= (char-code chara) (char-code #\9)))))
(defun letter-has-changed (previous new)
(if (and (is-number previous)
(is-number new))
t
(string= previous new)))
(defun print-index-letter (letter file)
(if (is-number letter)
(format file "~%<tr><th><a name=\"number\">#</a></th></tr>~%~%")
(let ((upletter (string-upcase letter)))
(format file "~%<tr><th><a name=\"~A\">~A</a></th></tr>~%~%" upletter upletter))))
(defun print-index-header (file)
(format file "<!DOCTYPE html>
<html>
<head>
<title>Quickref</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"https://sirgazil.bitbucket.io/static/docs/css/texinfo/tip/document.css\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\">
</head>
<body>
<div class=\"header\">
<p>Documentation generated with <a href=\"https://www.lrde.epita.fr/~~didier/software/lisp/misc.php#declt\">Declt</a>.</p>
</div>
<h1>Quickref</h1>
<div class=\"floating\">
<table><tr><th valign=\"top\">Jump to: &nbsp; </th>
<td>
<a class=\"summary-letter\" href=\"#number\"><b>#</b></a>
&nbsp~%")
(loop for c across "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
do (format file "<a class=\"summary-letter\" href=\"#~C\"><b>~C</b></a>
&nbsp;~%" c c))
(format file "</td>
</tr></table>
</div>
<table class=\"index-cp\" border=\"0\">
<tr><td></td><th align=\"left\">Index Entry</th></tr>~%"))
(defun build-index (path file-path)
(with-open-file (file file-path
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(print-index-header file)
(let* ((dir-list (get-directory-list path))
(first-letter (get-first-letter (first dir-list)))
(length 0)
(pos dir-list))
(loop until (endp pos)
do (if (letter-has-changed first-letter (get-first-letter (car pos)))
(progn (setq length (+ length 1))
(setq pos (cdr pos)))
(progn
(print-index-letter first-letter file)
(print-columns dir-list length file)
(setq length 0)
(setq dir-list pos)
(setq first-letter (get-first-letter (car pos))))))
(print-index-letter first-letter file)
(print-columns dir-list length file))
(format file "</body>~%")))
(in-package :quickref)
(defun get-columns-length (size)
(if (equal size 1) (values 1 0 0)
(multiple-value-bind (split remainder) (floor size 3)
(case remainder
(0 (values split split split))
(1 (values (+ split 1) (+ split 1) (- split 1)))
(2 (values (+ split 1) (+ split 1) split))))))
(defun build-cell (s)
(format nil "<td></td><td><a href=\"~A\">~A</a></td>" s s))
(defun print-columns (l size file)
(multiple-value-bind (lfirst lsecond lthird)
(get-columns-length size)
(do ((n 0 (+ n 1))
(f l (cdr f))
(s (nthcdr lfirst l) (cdr s))
(th (nthcdr (+ lfirst lsecond) l) (cdr th)))
((= n lfirst) nil)
(if (>= n lsecond)
(format file
"<tr>~A</tr>~%"
(build-cell (car f)))
(if (>= n lthird)
(format file
"<tr>~A~A</tr>~%"
(build-cell (car f)) (build-cell (car s)))
(format file
"<tr>~A~A~A</tr>~%"
(build-cell (car f)) (build-cell (car s)) (build-cell (car th))))))))
(defun format-dir-path (path)
(if (char= (char path (- (length path) 1))
#\/)
(concatenate 'string path "*.*")
(concatenate 'string path "/*.*")))
(defun get-directory-list (path)
(loop for dir in (directory (format-dir-path path))
collect (car (last (pathname-directory dir)))))
(defun get-first-letter (sequence)
(subseq sequence 0 1))
(defun is-number (string)
(let ((chara (char string 0)))
(and (>= (char-code chara) (char-code #\0))
(<= (char-code chara) (char-code #\9)))))
(defun letter-has-changed (previous new)
(if (and (is-number previous)
(is-number new))
t
(string= previous new)))
(defun print-index-letter (letter file)
(if (is-number letter)
(format file "~%<tr><th><a name=\"number\">#</a></th></tr>~%~%")
(let ((upletter (string-upcase letter)))
(format file "~%<tr><th><a name=\"~A\">~A</a></th></tr>~%~%" upletter upletter))))
(defun print-index-header (file)
(format file "<!DOCTYPE html>
<html>
<head>
<title>Quickref</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"https://sirgazil.bitbucket.io/static/docs/css/texinfo/tip/document.css\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\">
</head>
<body>
<div class=\"header\">
<p>Documentation generated with <a href=\"https://www.lrde.epita.fr/~~didier/software/lisp/misc.php#declt\">Declt</a>.</p>
</div>
<h1>Quickref</h1>
<div class=\"floating\">
<table><tr><th valign=\"top\">Jump to: &nbsp; </th>
<td>
<a class=\"summary-letter\" href=\"#number\"><b>#</b></a>
&nbsp~%")
(loop for c across "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
do (format file "<a class=\"summary-letter\" href=\"#~C\"><b>~C</b></a>
&nbsp;~%" c c))
(format file "</td>
</tr></table>
</div>
<table class=\"index-cp\" border=\"0\">
<tr><td></td><th align=\"left\">Index Entry</th></tr>~%"))
(defun build-index (path file-path)
(with-open-file (file file-path
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(print-index-header file)
(let* ((dir-list (get-directory-list path))
(first-letter (get-first-letter (first dir-list)))
(length 0)
(pos dir-list))
(loop until (endp pos)
do (if (letter-has-changed first-letter (get-first-letter (car pos)))
(progn (setq length (+ length 1))
(setq pos (cdr pos)))
(progn
(print-index-letter first-letter file)
(print-columns dir-list length file)
(setq length 0)
(setq dir-list pos)
(setq first-letter (get-first-letter (car pos))))))
(print-index-letter first-letter file)
(print-columns dir-list length file))
(format file "</body>~%")))
Supports Markdown
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