Merge pull request #138 from fgiasson/master
Add a new option to exclude source files from being processed by Margina...
This commit is contained in:
commit
a34b1c6606
3 changed files with 31 additions and 3 deletions
|
@ -43,6 +43,7 @@ Marginalia accepts options as described below:
|
||||||
* -c --css Additional css resources `<resource1>;<resource2>;...` (if not given will be taken from `project.clj`)
|
* -c --css Additional css resources `<resource1>;<resource2>;...` (if not given will be taken from `project.clj`)
|
||||||
* -j --js Additional javascript resources `<jsfile1>;<jsfile2>;...` (if not given will be taken from `project.clj`)
|
* -j --js Additional javascript resources `<jsfile1>;<jsfile2>;...` (if not given will be taken from `project.clj`)
|
||||||
* -m --multi Generate each namespace documentation as a separate file
|
* -m --multi Generate each namespace documentation as a separate file
|
||||||
|
* -e --exclude Exclude source file(s) from the document generation process `<file1>;<file2>;...` (if not given will be taken from `project.clj`)
|
||||||
|
|
||||||
### Maven
|
### Maven
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@ Marginalia is...
|
||||||
- [MerelyAPseudonym](https://github.com/MerelyAPseudonym)
|
- [MerelyAPseudonym](https://github.com/MerelyAPseudonym)
|
||||||
- [Ivan](https://github.com/ivantm)
|
- [Ivan](https://github.com/ivantm)
|
||||||
- [Benjamin Bader](https://github.com/benjamin-bader)
|
- [Benjamin Bader](https://github.com/benjamin-bader)
|
||||||
|
- [Frederick Giasson](https://github.com/fgiasson)
|
||||||
|
|
||||||
If I've missed your name then please ping me.
|
If I've missed your name then please ping me.
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,17 @@
|
||||||
[(if (= group artifact) artifact (str group "/" artifact))
|
[(if (= group artifact) artifact (str group "/" artifact))
|
||||||
version])))
|
version])))
|
||||||
|
|
||||||
|
(defn source-excluded?
|
||||||
|
"Check if a source file is excluded from the generated documentation"
|
||||||
|
[source opts]
|
||||||
|
(if-not (empty?
|
||||||
|
(filter #(if (re-find (re-pattern %) source)
|
||||||
|
true
|
||||||
|
false)
|
||||||
|
(-> opts :marginalia :exclude)))
|
||||||
|
true
|
||||||
|
false))
|
||||||
|
|
||||||
(defn run-marginalia
|
(defn run-marginalia
|
||||||
"Default generation: given a collection of filepaths in a project, find the .clj
|
"Default generation: given a collection of filepaths in a project, find the .clj
|
||||||
files at these paths and, if Clojure source files are found:
|
files at these paths and, if Clojure source files are found:
|
||||||
|
@ -245,7 +256,7 @@
|
||||||
|
|
||||||
If no source files are found, complain with a usage message."
|
If no source files are found, complain with a usage message."
|
||||||
[args & [project]]
|
[args & [project]]
|
||||||
(let [[{:keys [dir file name version desc deps css js multi leiningen]} files help]
|
(let [[{:keys [dir file name version desc deps css js multi leiningen exclude]} files help]
|
||||||
(cli args
|
(cli args
|
||||||
["-d" "--dir" "Directory into which the documentation will be written" :default "./docs"]
|
["-d" "--dir" "Directory into which the documentation will be written" :default "./docs"]
|
||||||
["-f" "--file" "File into which the documentation will be written" :default "uberdoc.html"]
|
["-f" "--file" "File into which the documentation will be written" :default "uberdoc.html"]
|
||||||
|
@ -259,7 +270,9 @@
|
||||||
["-j" "--js" "Additional javascript resources <resource1>;<resource2>;...
|
["-j" "--js" "Additional javascript resources <resource1>;<resource2>;...
|
||||||
If not given will be taken from project.clj"]
|
If not given will be taken from project.clj"]
|
||||||
["-m" "--multi" "Generate each namespace documentation as a separate file" :flag true]
|
["-m" "--multi" "Generate each namespace documentation as a separate file" :flag true]
|
||||||
["-l" "--leiningen" "Generate the documentation for a Leiningen project file."])
|
["-l" "--leiningen" "Generate the documentation for a Leiningen project file."]
|
||||||
|
["-e" "--exclude" "Exclude source file(s) from the document generation process <file1>;<file2>;...
|
||||||
|
If not given will be taken from project.clj"])
|
||||||
sources (distinct (format-sources (seq files)))
|
sources (distinct (format-sources (seq files)))
|
||||||
sources (if leiningen (cons leiningen sources) sources)]
|
sources (if leiningen (cons leiningen sources) sources)]
|
||||||
(if-not sources
|
(if-not sources
|
||||||
|
@ -274,6 +287,7 @@
|
||||||
marg-opts (merge-with choose
|
marg-opts (merge-with choose
|
||||||
{:css (when css (.split css ";"))
|
{:css (when css (.split css ";"))
|
||||||
:javascript (when js (.split js ";"))
|
:javascript (when js (.split js ";"))
|
||||||
|
:exclude (when exclude (.split exclude ";"))
|
||||||
:leiningen leiningen}
|
:leiningen leiningen}
|
||||||
(:marginalia project-clj))
|
(:marginalia project-clj))
|
||||||
opts (merge-with choose
|
opts (merge-with choose
|
||||||
|
@ -283,7 +297,10 @@
|
||||||
:dependencies (split-deps deps)
|
:dependencies (split-deps deps)
|
||||||
:multi multi
|
:multi multi
|
||||||
:marginalia marg-opts}
|
:marginalia marg-opts}
|
||||||
project-clj)]
|
project-clj)
|
||||||
|
sources (->> sources
|
||||||
|
(filter #(not (source-excluded? % opts)))
|
||||||
|
(into []))]
|
||||||
(println "Generating Marginalia documentation for the following source files:")
|
(println "Generating Marginalia documentation for the following source files:")
|
||||||
(doseq [s sources]
|
(doseq [s sources]
|
||||||
(println " " s))
|
(println " " s))
|
||||||
|
|
|
@ -131,6 +131,15 @@
|
||||||
;; to project.clj. Below is a simple example of both inline and block
|
;; to project.clj. Below is a simple example of both inline and block
|
||||||
;; formatted equations.
|
;; formatted equations.
|
||||||
;;
|
;;
|
||||||
|
;; Optionally, you can put the MathJax CDN URL directly as a value of `:javascript`
|
||||||
|
;; like this:
|
||||||
|
;;
|
||||||
|
;; :marginalia {
|
||||||
|
;; :javascript
|
||||||
|
;; ["http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"]}
|
||||||
|
;;
|
||||||
|
;; That way you won't have to download and carry around the MathJax library.
|
||||||
|
;;
|
||||||
;; When \\(a \ne 0\\), there are two solutions to \\(ax^2 + bx + c = 0\\) and they are
|
;; When \\(a \ne 0\\), there are two solutions to \\(ax^2 + bx + c = 0\\) and they are
|
||||||
;; $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
|
;; $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue