Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/deleinization #56

Merged
merged 3 commits into from
Sep 7, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 38 additions & 9 deletions src/marginalia/core.clj
Expand Up @@ -204,6 +204,12 @@
(defn usage []
(println "marginalia <src1> ... <src-n>"))

(defn split-deps [deps]
(for [d (.split deps ";")
:let [[group artifact version] (.split d ":")]]
[(if (= group artifact) artifact (str group "/" artifact))
version]))

(defn run-marginalia
"Default generation: given a collection of filepaths in a project, find the .clj
files at these paths and, if Clojure source files are found:
Expand All @@ -220,22 +226,45 @@
"Usage: lein marg <options?> <src1> ... <src-n>\n")
[[dir d "Directory into which the documentation will be written" "./docs"]
[file f "File into which the documentation will be written" "uberdoc.html"]
[name n "Project name - if not given will be taken from project.clj"]
[version v "Project version - if not given will be taken from project.clj"]
[desc D "Project description - if not given will be taken from project.clj"]
[deps a "Project dependencies in the form <group1>:<artifact1>:<version1>;<group2>...
If not given will be taken from project.clj"]
[css c "Additional css resources <resource1>;<resource2>;...
If not given will be taken from project.clj."]
[js j "Additional javascript resources <resource1>;<resource2>;...
If not given will be taken from project.clj"]
src]
(let [sources (format-sources (seq src))]
(if-not sources
(do
(println "Wrong number of arguments passed to marginalia.")
(print-help))
(binding [*docs* dir]
(println "Generating uberdoc for the following source files:")
(doseq [s sources]
(println " " s))
(println)
(ensure-directory! *docs*)
(uberdoc! (str *docs* "/" file) sources (parse-project-file))
(println "Done generating your documentation, please see"
(str *docs* "/" file))
(println ""))))))
(let [project-clj (when (.exists (io/file "project.clj"))
(parse-project-file))
choose #(or %1 %2)
marg-opts (merge-with choose
{:css (when css (.split css ";"))
:javascript (when js (.split js ";"))}
(:marginalia project-clj))
opts (merge-with choose
{:name name
:version version
:description desc
:dependencies (split-deps deps)
:marginalia marg-opts}
project-clj)]
(println "Generating uberdoc for the following source files:")
(doseq [s sources]
(println " " s))
(println)
(ensure-directory! *docs*)
(uberdoc! (str *docs* "/" file) sources opts)
(println "Done generating your documentation, please see"
(str *docs* "/" file))
(println "")))))))

(defn -main
"The main entry point into Marginalia."
Expand Down
19 changes: 10 additions & 9 deletions src/marginalia/html.clj
Expand Up @@ -110,15 +110,16 @@
"")]))

(defn dependencies-html [deps & header-name]
(let [header-name (or header-name "dependencies")]
(html [:div {:class "dependencies"}
[:h3 header-name]
[:table
(map #(html [:tr
[:td {:class "dep-name"} (str (first %))]
[:td {:class "dotted"} [:hr]]
[:td {:class "dep-version"} (second %)]])
deps)]])))
(when-let [deps (seq deps)]
(let [header-name (or header-name "dependencies")]
(html [:div {:class "dependencies"}
[:h3 header-name]
[:table
(map #(html [:tr
[:td {:class "dep-name"} (str (first %))]
[:td {:class "dotted"} [:hr]]
[:td {:class "dep-version"} (second %)]])
deps)]]))))

(defn cake-plugins-html [tasks]
(when tasks
Expand Down