forked from szermatt/visual-replace
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEldev
90 lines (77 loc) · 3.42 KB
/
Eldev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
; -*- mode: emacs-lisp; lexical-binding: t -*-
(setq eldev-build-treat-warnings-as-errors t)
(setf eldev-project-loading-mode 'byte-compiled)
(setq sentence-end-double-space nil)
(eldev-use-plugin 'autoloads)
(eldev-use-plugin 'maintainer)
(setq eldev-release-test-local t)
(eldev-add-loading-roots 'test "test")
(eldev-use-package-archive 'gnu-elpa)
(eldev-add-extra-dependencies '(test emacs) 'turtles)
(eldev-use-vc-repository
'turtles :github "szermatt/turtles" :commit "2.0.0")
;; Exclude work and build files so Eldev doctor ignores them.
(setf eldev-standard-excludes
`(:or ,eldev-standard-excludes
"./venv" "./docs/build" "./license" "./deps"))
;;; Documentation
(eldev-defbuilder visual-replace-builder-build-info (source target)
:short-name "SPHINX-TEXI"
:message source-and-target
:type many-to-one
:source-files "docs/source/*.rst"
:targets ("visual-replace.texi")
:collect ":default"
(visual-replace-eldev-build-texinfo))
(defun visual-replace-eldev-build-texinfo ()
(eldev-call-process "sphinx-build" '("-M" "texinfo" "docs/source" "docs/build")
:forward-output t
:die-on-error t)
;; Remove the date and version to keep the output stable from change
;; to change.
(with-temp-buffer
(insert-file-contents "docs/build/texinfo/visual-replace.texi")
(goto-char (point-min))
(search-forward-regexp "@\\*Generated by Sphinx [0-9.]+\\(snapshot\\)?\\.@\\*")
(replace-match "@*Generated by Sphinx.@*")
(goto-char (point-min))
(search-forward-regexp "@quotation\nVisual-Replace [0-9.]+\\(snapshot\\)?\\(, .*\\)$")
(replace-match "@quotation\nVisual-Replace")
(write-file "visual-replace.texi")))
(eldev-defcommand visual-replace-html-doc (&rest parameters)
"Generate documentation HTML into docs/build/html.
First install Sphinx with:
python3 -m venv venv
. venv/bin/activate
pip3 install -r docs/requirements.txt"
:command documentation
:aliases (html)
(eldev-call-process "sphinx-build" '("-M" "html" "docs/source" "docs/build")
:forward-output t
:die-on-error t))
(eldev-defcleaner visual-replace-cleaner-docs ()
"Delete Sphinx build dir"
:default t
'("docs/build"))
(defun visual-replace-release-preparator (version &optional post-release-version)
(eldev-with-file-buffer "docs/source/conf.py"
(dolist (tag '("version" "release"))
(goto-char (point-min))
(search-forward-regexp (concat tag " = '\\([0-9.]+\\(snapshot\\)?\\)' *$"))
(replace-match
(format "%s = '%s'" tag (package-version-join
(or post-release-version version))))))
(visual-replace-eldev-build-texinfo))
(add-hook 'eldev-release-preparators #'visual-replace-release-preparator)
;; After a release, add a snapshot to tag a development version, so if the
;; release is 1.0.0, the following development version is 1.0.1snapshot
;; and the next release is going to be 1.0.2 or 1.1.
(setq eldev-release-post-release-commit
(lambda (release-version)
(let ((major (or (nth 0 release-version) 0))
(minor (or (nth 1 release-version) 0))
(patch (or (nth 2 release-version) 0)))
(list major minor (1+ patch) -4))))
(setq eldev-release-post-release-commit-message
"Development version, following release @[version-string]@")
(add-hook 'eldev-release-post-release-preparators #'visual-replace-release-preparator)