Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

Commit 6ef6c7f

Browse files
committed
Initial commit.
0 parents  commit 6ef6c7f

8 files changed

+244
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.fasl
2+
*.dx32fsl
3+
*.dx64fsl
4+
*.lx32fsl
5+
*.lx64fsl
6+
*.x86f
7+
*~
8+
.#*

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "modules/quicklisp-projects"]
2+
path = modules/quicklisp-projects
3+
url = https://github.com/quicklisp/quicklisp-projects

README.markdown

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Quickdocs-Updater
2+
3+
## Usage
4+
5+
## Installation
6+
7+
## Author
8+
9+
* Eitaro Fukamachi ([email protected])
10+
11+
## Copyright
12+
13+
Copyright (c) 2015 Eitaro Fukamachi ([email protected])
14+
15+
## License
16+
17+
Licensed under the BSD 2-Clause License.

modules/quicklisp-projects

Submodule quicklisp-projects added at bd197a3

quickdocs-updater.asd

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#|
2+
This file is a part of quickdocs-updater project.
3+
Copyright (c) 2015 Eitaro Fukamachi ([email protected])
4+
|#
5+
6+
#|
7+
Author: Eitaro Fukamachi ([email protected])
8+
|#
9+
10+
(in-package :cl-user)
11+
(defpackage quickdocs-updater-asd
12+
(:use :cl :asdf))
13+
(in-package :quickdocs-updater-asd)
14+
15+
(defsystem quickdocs-updater
16+
:version "0.1"
17+
:author "Eitaro Fukamachi"
18+
:license "BSD 2-Clause"
19+
:depends-on (:quickdocs-extracter
20+
:quickdocs-database
21+
:cl-ppcre
22+
:quri
23+
:uiop
24+
:alexandria
25+
:split-sequence)
26+
:components ((:module "src"
27+
:components
28+
((:file "quickdocs-updater"))))
29+
:description "Updates Quickdocs database"
30+
:long-description
31+
#.(with-open-file (stream (merge-pathnames
32+
#p"README.markdown"
33+
(or *load-pathname* *compile-file-pathname*))
34+
:if-does-not-exist nil
35+
:direction :input)
36+
(when stream
37+
(let ((seq (make-array (file-length stream)
38+
:element-type 'character
39+
:fill-pointer t)))
40+
(setf (fill-pointer seq) (read-sequence seq stream))
41+
seq))))

src/extracter.lisp

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
(in-package :cl-user)
2+
(defpackage quickdocs-updater.extracter
3+
(:use :cl)
4+
(:export :extract-result-directory
5+
:extractedp
6+
:run-extract-dist
7+
:release-systems-info)
8+
(:documentation "Functions for controlling quickdocs-extracter"))
9+
(in-package :quickdocs-updater.extracter)
10+
11+
(defparameter *extract-result-directory*
12+
(asdf:system-relative-pathname :quickdocs-updater #P"dists/"))
13+
14+
(defun extract-result-directory (dist)
15+
(merge-pathnames (ql-dist:version dist) *extract-result-directory*))
16+
17+
(defun extract-result-of-release (release)
18+
(merge-pathnames (ql-dist:name release) (extract-result-directory (ql-dist:dist release))))
19+
20+
(defun extractedp (dist)
21+
(uiop:directory-exists-p (extract-result-directory dist)))
22+
23+
(defun run-extract-dist (dist)
24+
(let ((extract-dist-script (asdf:system-relative-pathname #P"scripts/extract-dist" :quickdocs-extracter))
25+
(*default-pathname-defaults*
26+
(uiop:pathname-parent-directory-pathname *extract-result-directory*)))
27+
(uiop:run-program `(,extract-dist-script ,(ql-dist:version dist))
28+
:output *standard-output*
29+
:error-output *error-output*))
30+
(extract-result-directory dist))
31+
32+
(defun release-systems-info (release)
33+
(check-type release ql-dist:release)
34+
(let ((result-file (extract-result-of-release release)))
35+
(unless (uiop:file-exists-p result-file)
36+
(restart-case
37+
(error "Extracted release info of ~S does not exist." (ql-dist:name release))
38+
;; For testing mainly.
39+
(extract-now ()
40+
:report "Extract it now in the current thread"
41+
(return-from release-systems-info
42+
(getf (quickdocs-extracter:serialize-release
43+
(ql-dist:name release)
44+
(ql-dist:dist release))
45+
:systems)))))
46+
(with-open-file (in result-file)
47+
(uiop:with-safe-io-syntax ()
48+
(loop with eof = '#:eof
49+
for form = (read in nil eof)
50+
until (eq form eof)
51+
collect form)))))

src/quickdocs-updater.lisp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(in-package :cl-user)
2+
(defpackage quickdocs-updater
3+
(:use :cl)
4+
(:import-from :quickdocs-updater.extracter
5+
:run-extract-dist))
6+
(in-package :quickdocs-updater)
7+
8+
(defun update-dist (dist)
9+
(check-type dist ql-dist:dist)
10+
(run-extract-dist dist)
11+
(dolist (release (ql-dist:provided-releases dist))
12+
(update-release release)))
13+
14+
(defun update-release (release)
15+
(check-type release ql-dist:release))

src/release.lisp

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
(in-package :cl-user)
2+
(defpackage quickdocs-updater.release
3+
(:use :cl
4+
:split-sequence)
5+
(:import-from :quickdocs-updater.extracter
6+
:extractedp
7+
:extract-result-directory
8+
:release-systems-info)
9+
(:import-from :alexandria
10+
:when-let
11+
:starts-with-subseq
12+
:compose
13+
:ignore-some-conditions)
14+
(:export :readme-file
15+
:release-version
16+
:primary-system
17+
:project-homepage)
18+
(:documentation "Function/method collections for Quicklisp releases."))
19+
(in-package :quickdocs-updater.release)
20+
21+
(defun readme-file (release)
22+
(check-type release ql-dist:release)
23+
(assert (ql-dist:installedp release))
24+
(find "README"
25+
(uiop:directory-files (ql-dist:base-directory release))
26+
:key #'pathname-name
27+
:test #'string=))
28+
29+
(defun release-version (release)
30+
"Return the latest Quicklisp dist version that `release` was updated."
31+
(check-type release ql-dist:release)
32+
(when-let (match (nth-value 1
33+
(ppcre:scan-to-strings "beta\\.quicklisp\\.org/archive/[^/]+/([^/]+)"
34+
(ql-dist:archive-url release))))
35+
(aref match 0)))
36+
37+
(defun primary-system (release)
38+
(check-type release ql-dist:release)
39+
(flet ((remove-cl-prefix (name)
40+
(if (starts-with-subseq "cl-" name)
41+
(subseq name 3)
42+
name)))
43+
(let ((project-name (remove-cl-prefix (ql-dist:project-name release)))
44+
(provided-systems (ql-dist:provided-systems release)))
45+
(or (find project-name
46+
provided-systems
47+
:key (compose #'remove-cl-prefix #'ql-dist:name)
48+
:test #'string=)
49+
(first provided-systems)))))
50+
51+
;; NOTE: quicklisp-projects is updated every month and it could be different from the `release' has been included.
52+
;; It would be a problem when updating old dists.
53+
(defun project-source-txt (release)
54+
(check-type release ql-dist:release)
55+
(merge-pathnames (format nil "~A/source.txt" (ql-dist:name release))
56+
(asdf:system-relative-pathname :quickdocs-database
57+
#P"modules/quicklisp-projects/")))
58+
59+
(defun project-source-info (release)
60+
(check-type release ql-dist:release)
61+
(let ((data (uiop:read-file-string (project-source-txt release))))
62+
(destructuring-bind (type source-url)
63+
(split-sequence #\Space data :count 2)
64+
(values type source-url))))
65+
66+
(defun project-homepage (release)
67+
(check-type release ql-dist:release)
68+
(let ((systems-info (release-systems-info release)))
69+
(or
70+
;; Use if :homepage exists in ASD files
71+
(getf (find-if (lambda (info)
72+
(getf info :homepage))
73+
systems-info)
74+
:homepage)
75+
76+
;; Use the repository URL if it's on some popular services, like GitHub or BitBucket
77+
(multiple-value-bind (type source-url)
78+
(project-source-info release)
79+
(ignore-some-conditions (quri:uri-error)
80+
(let* ((uri (quri:uri source-url))
81+
(domain (quri:uri-domain uri)))
82+
(cond
83+
((string= domain "github.com")
84+
(let ((repos-id (ppcre:regex-replace "\\.[^\\.]*$" (quri:uri-path uri) "")))
85+
;; TODO: request website URL to GitHub
86+
(concatenate 'string
87+
"https://github.com"
88+
repos-id)))
89+
((string= domain "bitbucket.org")
90+
;; TODO: request website URL to BitBucket
91+
source-url)
92+
((string= domain "gitlab.common-lisp.net")
93+
(let ((repos-id (ppcre:regex-replace "\\.[^\\.]*$" (quri:uri-path uri) "")))
94+
(concatenate 'string
95+
"http://gitlab.common-lisp.net"
96+
repos-id)))
97+
((string= domain "common-lisp.net")
98+
(let ((match (ppcre:scan-to-strings "://common-lisp\\.net/project/([^\\/]+)" source-url)))
99+
(format nil "http://common-lisp.net/project/~A"
100+
(quri:url-encode
101+
(if match
102+
(aref match 0)
103+
(ql-dist:project-name release))
104+
:encoding :utf-8))))
105+
((or (string= domain "weitz.de")
106+
(string= type "ediware-http"))
107+
(format nil "http://weitz.de/~A/"
108+
(quri:url-encode (ql-dist:project-name release) :encoding :utf-8))))))))))

0 commit comments

Comments
 (0)