From db80a2abbc3c9cab0006108bffb3597bc557dab4 Mon Sep 17 00:00:00 2001 From: zkim Date: Fri, 7 Jan 2011 10:40:40 -0700 Subject: [PATCH] Changed html title tag to include project name, added meta description tag, updated example output. Closes #7 --- example-output/uberdoc.html | 111 +++++++++++++++++++++++++++++------- src/marginalia/html.clj | 8 ++- 2 files changed, 95 insertions(+), 24 deletions(-) diff --git a/example-output/uberdoc.html b/example-output/uberdoc.html index eac8d53..39ba3cc 100644 --- a/example-output/uberdoc.html +++ b/example-output/uberdoc.html @@ -1,5 +1,5 @@ -Marginalia Output

marginalia

0.2.1


lightweight literate programming for clojure -- inspired by docco

-

dependencies

org.clojure/clojure
1.2.0
org.clojars.nakkaya/markdownj
1.0.2b4
hiccup
0.3.0

dev dependencies

lein-clojars
0.5.0-SNAPSHOT
jline
0.9.94
swank-clojure
1.2.1
hiccup
0.3.0
org.clojars.nakkaya/markdownj
1.0.2b4
marginalia
0.2.1

cake plugin namespaces

  • marginalia.tasks



(this space intentionally left blank)
 

Core provides all of the functionality around parsing clojure source files +marginalia -- Marginalia

marginalia

0.3.0


lightweight literate programming for clojure -- inspired by docco

+

dependencies

org.clojure/clojure
1.2.0
org.clojars.nakkaya/markdownj
1.0.2b4
hiccup
0.3.0

dev dependencies

lein-clojars
0.5.0-SNAPSHOT
jline
0.9.94
swank-clojure
1.2.1
hiccup
0.3.0
org.clojars.nakkaya/markdownj
1.0.2b4
marginalia
0.3.0

cake plugin namespaces

  • marginalia.tasks



(this space intentionally left blank)
 

Core provides all of the functionality around parsing clojure source files into an easily consumable format.

(ns marginalia.core
   (:require [clojure.java.io :as io]
             [clojure.string  :as str])
   (:use [marginalia.html :only (uberdoc-html)]
-        [clojure.contrib.find-namespaces :only (read-file-ns-decl)]))
+        [clojure.contrib.find-namespaces :only (read-file-ns-decl)])
+  (:gen-class))
 
(def *test* "./src/cljojo/core.clj")
@@ -2657,7 +2658,19 @@ current line start with a quote?

(and (re-find #"^\(deftask" (str/trim last-code-text))

Is the last line's code-text the start of a ns decl, and does the current line start with a quote?

            (re-find #"^\"" (str/trim (str line))))
-       (and (re-find #"^\(ns" last-code-text)

Is the prev line a docstring, prev line not end with a quote, + (and (re-find #"^\(ns" last-code-text)

Is the last line's code-text the start of a defprotocol, +and does the current line start with a quote?

+
            (re-find #"^\"" (str/trim (str line))))
+       (and (re-find #"^\(defprotocol" last-code-text)

Is the last line's code-text the start of a defmulti, +and does the current line start with a quote?

+
            (re-find #"^\"" (str/trim (str line))))
+       (and (re-find #"^\(defmulti" last-code-text)

Is the last line's code-text the start of a defmethod, +and does the current line start with a quote?

+
            (re-find #"^\"" (str/trim (str line))))
+       (and (re-find #"^\(defmethod" last-code-text)

Is the last line's code-text the start of a defmacro, +and does the current line start with a quote?

+
            (re-find #"^\"" (str/trim (str line))))       
+       (and (re-find #"^\(defmacro" last-code-text)

Is the prev line a docstring, prev line not end with a quote, and the current line empty?

            (re-find #"^\"" (str/trim (str line))))
        (and (:docstring-text l)

Is the prev line a docstring, the prev line not end with a quote, @@ -2755,24 +2768,22 @@ I wonder?

(ensure-directory! "./docs") (uberdoc! "./docs/uberdoc.html" sources) (println "Done generating your docs, please see ./docs/uberdoc.html") - (println)))))

main docstring -Multi line

+ (println)))))

The main entry point into Marginalia.

 (defn -main
-  [sources]
+  [& sources]
   (run-marginalia sources))
 

Example Usage

-
-(comment

Command line example

-
-  (-main ["./src/marginalia/core.clj" "./src/marginalia/html.clj"])

This will find all marginalia source files, and then generate an uberdoc.

+

Command line example

+
(comment
+  (-main "./src/marginalia/core.clj" "./src/marginalia/html.clj")

This will find all marginalia source files, and then generate an uberdoc.

  
-  (-main (find-clojure-file-paths "./src"))

Move these to tests

+ (apply -main (find-clojure-file-paths "./src"))

Move these to tests

   (merge-line {:docstring-text "hello world" :line 3} {:docs ["stuff"]})
   (merge-line {:code-text "(defn asdf" :line 4} {:docs ["stuff"]})
-  (merge-line {:docs-text "There's only one method in this module", :line 4} {}))
-
 

Utilities for converting parse results into html.

+ (merge-line {:docs-text "There's only one method in this module", :line 4} {}) +)
 

Utilities for converting parse results into html.

Plus a few other goodies.

@@ -3117,11 +3128,13 @@ $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$

saying that all this is WIP and will prabably change in the future.

 (defn page-template
-  [opt-resources header toc floating-toc content]
+  [project-metadata opt-resources header toc floating-toc content]
   (html
    (doctype :html5)
    [:html
     [:head
+     [:meta {:http-equiv "Content-Type" :content "text/html" :charset "utf-8"}]
+     [:meta {:name "description" :content (:description project-metadata)}]
      (inline-js "jquery-1.4.4.min.js")
      (inline-js "xregexp-min.js")
      (inline-js "shCore.js")
@@ -3137,7 +3150,7 @@ saying that all this is WIP and will prabably change in the future.

floating-toc-css general-css opt-resources - [:title "Marginalia Output"]] + [:title (:name project-metadata) " -- Marginalia"]] [:body [:table header @@ -3145,7 +3158,7 @@ saying that all this is WIP and will prabably change in the future.

content] [:div {:class "footer"} "Generated by " - [:a {:href "https://github.com/fogus/marginalia"} "marginalia"] + [:a {:href "https://github.com/fogus/marginalia"} "Marginalia"] ".  " "Syntax highlighting provided by Alex Gorbatchev's " [:a {:href "http://alexgorbatchev.com/SyntaxHighlighter/"} @@ -3163,6 +3176,7 @@ It's probably the only var consumers will use.

(defn uberdoc-html [output-file-name project-metadata docs] (page-template + project-metadata (opt-resources-html project-metadata) (header-html project-metadata) (toc-html docs) @@ -3173,7 +3187,7 @@ It's probably the only var consumers will use.

Usage

    -
  1. In your project.clj, add [marginalia "0.2.1"] to your:dev-dependenciesandmarginalia.tasksto:tasks`
  2. +
  3. In your project.clj, add [marginalia "<current version number>"] to your:dev-dependenciesandmarginalia.tasksto:tasks`
  4. Run cake marg from within your project directory.
(ns marginalia.tasks
@@ -3188,7 +3202,7 @@ Optionally, you can pass files or directories to control what documentation is g
 

Usage

    -
  1. Add [marginalia "0.2.1"] to your project.clj's :dev-dependencies section.
  2. +
  3. Add [marginalia "<current version number>"] to your project.clj's :dev-dependencies section.
  4. run lein marg from your project's root directory.
(ns leiningen.marg
@@ -3222,5 +3236,60 @@ See https://github
 (defn parse-bool [v] (condp = (.trim (text v))
                          "0" false
                          "1" true
-                         "throw exception here"))
 

\ No newline at end of file diff --git a/src/marginalia/html.clj b/src/marginalia/html.clj index f0aeaab..867191d 100644 --- a/src/marginalia/html.clj +++ b/src/marginalia/html.clj @@ -351,12 +351,13 @@ "Notice that we're inlining the css & javascript for [SyntaxHighlighter](http://alexgorbatchev.com/SyntaxHighlighter/) (`inline-js` & `inline-css`) to be able to package the output as a single file (uberdoc if you will). It goes without saying that all this is WIP and will prabably change in the future." - [opt-resources header toc floating-toc content] + [project-metadata opt-resources header toc floating-toc content] (html (doctype :html5) [:html [:head [:meta {:http-equiv "Content-Type" :content "text/html" :charset "utf-8"}] + [:meta {:name "description" :content (:description project-metadata)}] (inline-js "jquery-1.4.4.min.js") (inline-js "xregexp-min.js") (inline-js "shCore.js") @@ -372,7 +373,7 @@ floating-toc-css general-css opt-resources - [:title "Marginalia Output"]] + [:title (:name project-metadata) " -- Marginalia"]] [:body [:table header @@ -380,7 +381,7 @@ content] [:div {:class "footer"} "Generated by " - [:a {:href "https://github.com/fogus/marginalia"} "marginalia"] + [:a {:href "https://github.com/fogus/marginalia"} "Marginalia"] ".  " "Syntax highlighting provided by Alex Gorbatchev's " [:a {:href "http://alexgorbatchev.com/SyntaxHighlighter/"} @@ -400,6 +401,7 @@ It's probably the only var consumers will use." [output-file-name project-metadata docs] (page-template + project-metadata (opt-resources-html project-metadata) (header-html project-metadata) (toc-html docs)