diff --git a/example-output/uberdoc.html b/example-output/uberdoc.html index 8a96a6fd..ce64271b 100644 --- a/example-output/uberdoc.html +++ b/example-output/uberdoc.html @@ -2077,7 +2077,101 @@ SyntaxHighlighter.brushes.Clojure.aliases = ['clojure', 'Clojure', 'clj']; // vim: ts=2 sw=2 noet -Marginalia Output

marginalia

0.0.1


A port of Docco to Clojure.

+Marginalia Output

marginalia

0.1.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



(this space intentionally left blank)
 

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

(ns marginalia.core
@@ -2819,7 +2913,108 @@ 

Plus a few other goodies.

(map group-to-html (:groups doc)) [:tr [:td {:class "spacer docs"} " "] - [:td {:class "codes"}]]))

Notice that we're inlining the css & javascript for SyntaxHighlighter (inline-js + [:td {:class "codes"}]]))

+
+(def reset-css
+  (css [:html {:margin 0 :padding 0}]
+       [:h1 {:margin 0 :padding 0}]
+       [:h2 {:margin 0 :padding 0}]
+       [:h3 {:margin 0 :padding 0}]
+       [:h4 {:margin 0 :padding 0}]))
+
+(def header-css
+  (css [:h1.project-name {:font-size "34px"
+                          :display "inline"}]
+       [:h2.project-version {:font-size "18px"
+                             :margin-top 0
+                             :display "inline"
+                             :margin-left "10px"}]
+       [:.toc-link {:font-size "12px"
+                    :margin-left "10px"
+                    :color "#252519"
+                    :text-decoration "none"}]
+       [:.toc-link:hover {:color "#5050A6"}]
+       [:.toc :h1 {:font-size "34px"
+                   :margin 0}]
+       [:.docs-header {:border-bottom "dotted #aaa 1px"
+                       :padding-bottom "10px"
+                       :margin-bottom "25px"}]
+       [:.toc :h1 {:font-size "24px"}]
+       [:.toc {:border-bottom "solid #bbb 1px"
+               :margin-bottom "40px"}]
+       [:.toc :ul {:margin-left "20px"
+                   :padding-left "0px"
+                   :padding-top 0
+                   :margin-top 0}]
+       [:.toc :li {:list-style-type "none"
+                   :padding-left 0}]
+       [:.dependencies {}]
+       [:.dependencies :table {:font-size "16px"
+                               :width "99.99%"
+                               :border "none"
+                               :margin-left "20px"}]
+       [:.dependencies :td {:padding-right "20px;"
+                            :white-space "nowrap"}]
+       [:.dependencies :.dotted {:width "99%"}]
+       [:.dependencies :.dotted :hr {:height 0
+                                     :noshade "noshade"
+                                     :color "transparent"
+                                     :background-color "transparent"
+                                     :border-bottom "dotted #bbb 1px"
+                                     :border-top "none"
+                                     :border-left "none"
+                                     :border-right "none"
+                                     :margin-bottom "-6px"}]
+       [:.dependencies :.dep-version {:text-align "right"}]
+       [:.header :p {:margin-left "20px"}]))
+
+(def floating-toc-css
+  (css [:#floating-toc {:position "fixed"
+                        :top "10px"
+                        :right "20px"
+                        :height "20px"
+                        :overflow "hidden"
+                        :text-align "right"}]
+       [:#floating-toc :li {:list-style-type "none"
+                            :margin 0
+                            :padding 0}]))
+
+(def general-css
+  (css
+   [:body {:margin 0
+           :padding 0
+           :font-family "'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;"
+           :font-size "16px"
+           :color "#252519"}]
+   [:h1 {:font-size "20px"
+         :margin-top 0}]
+   [:.anchor {:text-decoration "none"
+              :color "#252519"}]
+   [:.anchor:hover {:color "#5050A6"}]
+   [:table {:border-spacing 0
+            :border-bottom "solid #ddd 1px;"
+            :margin-bottom "10px"}]
+   [:code {:display "inline"}]
+   [:p {:margin-top "8px"}]
+   [:tr {:margin "0px"
+         :padding "0px"}]
+   [:td.docs {:width "45%"
+              :vertical-align "top"
+              :margin "0px"
+              :padding-left "55px"
+              :padding-right "20px"
+              :border "none"}]
+   [:td.codes {:width "55%"
+               :background-color "#F5F5FF"
+               :vertical-align "top"
+               :margin "0px"
+               :padding-left "20px"
+               :border "none"
+               :overflow "hidden"
+               :font-size "10pt"
+               :border-left "solid #ddd 1px"}]
+   [:td.spacer {:padding-bottom "40px"}]
+   [:.footer {:text-align "center"}]))

Notice that we're inlining the css & javascript for 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.

@@ -2832,103 +3027,14 @@ 

Plus a few other goodies.

(inline-js "xregexp-min.js") (inline-js "shCore.js") (inline-js "shBrushClojure.js") - #_ (inline-js "app.js") - [:script {:type "text/javascript" :src "./../resources/app.js"}] + (inline-js "app.js") + #_[:script {:type "text/javascript" :src "./../resources/app.js"}] (inline-css "shCore.css") (inline-css "shThemeEclipse.css") - (css - [:html {:margin 0 :padding 0}] - [:h1 {:margin 0 :padding 0}] - [:h2 {:margin 0 :padding 0}] - [:h3 {:margin 0 :padding 0}] - [:h4 {:margin 0 :padding 0}] - - [:body {:margin 0 - :padding 0 - :font-family "'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;" - :font-size "16px" - :color "#252519"}] - [:.toc-link {:font-size "12px" - :margin-left "10px" - :color "#252519" - :text-decoration "none"}] - [:.toc-link:hover {:color "#5050A6"}] - [:.docs-header {:border-bottom "dotted #aaa 1px" - :padding-bottom "10px" - :margin-bottom "25px"}] - [:.anchor {:text-decoration "none" - :color "#252519"}] - [:.anchor:hover {:color "#5050A6"}] - [:.toc :h1 {:font-size "34px" - :margin 0}] - [:h1 {:font-size "20px" - :margin-top 0}] - [:h1.project-name {:font-size "34px" - :display "inline"}] - [:h2.project-version {:font-size "18px" - :margin-top 0 - :display "inline" - :margin-left "10px"}] - [:table {:border-spacing 0 - :border-bottom "solid #ddd 1px;" - :margin-bottom "10px"}] - [:code {:display "inline"}] - [:p {:margin-top "8px"}] - [:tr {:margin "0px" - :padding "0px"}] - [:td.docs {:width "45%" - :vertical-align "top" - :margin "0px" - :padding-left "55px" - :padding-right "20px" - :border "none"}] - [:td.codes {:width "55%" - :background-color "#F5F5FF" - :vertical-align "top" - :margin "0px" - :padding-left "20px" - :border "none" - :overflow "hidden" - :font-size "10pt" - :border-left "solid #ddd 1px"}] - [:td.spacer {:padding-bottom "40px"}] - [:.toc :h1 {:font-size "24px"}] - [:.toc {:border-bottom "solid #bbb 1px" - :margin-bottom "40px"}] - [:.toc :ul {:margin-left "20px" - :padding-left "0px" - :padding-top 0 - :margin-top 0}] - [:.toc :li {:list-style-type "none" - :padding-left 0}] - [:.footer {:text-align "center"}] - [:#floating-toc {:position "fixed" - :top "10px" - :right "20px" - :height "20px" - :overflow "hidden"}] - [:#floating-toc :li {:list-style-type "none" - :margin 0 - :padding 0}] - [:.dependencies {}] - [:.dependencies :table {:font-size "16px" - :width "99.99%" - :border "none" - :margin-left "20px"}] - [:.dependencies :td {:padding-right "20px;" - :white-space "nowrap"}] - [:.dependencies :.dotted {:width "99%"}] - [:.dependencies :.dotted :hr {:height 0 - :noshade "noshade" - :color "transparent" - :background-color "transparent" - :border-bottom "dotted #bbb 1px" - :border-top "none" - :border-left "none" - :border-right "none" - :margin-bottom "-6px"}] - [:.dependencies :.dep-version {:text-align "right"}] - [:.header :p {:margin-left "20px"}]) + reset-css + header-css + floating-toc-css + general-css [:title "Marginalia Output"]] [:body [:table @@ -2946,9 +3052,6 @@

Plus a few other goodies.

[:script {:type "text/javascript"} "SyntaxHighlighter.defaults['gutter'] = false; SyntaxHighlighter.all()"]]])) - - -

Syntax highlighting is done a bit differently than docco. Instead of embedding the higlighting metadata on the parse / html gen phase, we use SyntaxHighlighter to do it in javascript.

diff --git a/src/marginalia/core.clj b/src/marginalia/core.clj index a32cafb9..2fdb63d3 100644 --- a/src/marginalia/core.clj +++ b/src/marginalia/core.clj @@ -6,6 +6,7 @@ (:use [marginalia.html :only (uberdoc-html)] [clojure.contrib.find-namespaces :only (read-file-ns-decl)])) + (def *test* "./src/cljojo/core.clj") (def *docs* "docs") (def *comment* #"^\s*;;\s?") @@ -141,7 +142,7 @@ (recur more cnum (inc dnum) - (conj sections {:docs-text (str (str/replace line *comment* "")) :line (+ cnum (dec dnum))})) + (conj sections {:docs-text (str (str/replace line *comment* "")) :line (+ cnum dnum)})) (recur more (inc cnum) 0 @@ -207,7 +208,7 @@ (println "Done generating your docs, please see ./docs/marg.html") (println)))) -(-main (find-clojure-file-paths "./src")) +#_(-main (find-clojure-file-paths "./src")) ;; # Example Usage diff --git a/src/marginalia/html.clj b/src/marginalia/html.clj index 4bc8b5f7..1f108aea 100644 --- a/src/marginalia/html.clj +++ b/src/marginalia/html.clj @@ -177,6 +177,107 @@ [:td {:class "spacer docs"} " "] [:td {:class "codes"}]])) +(def reset-css + (css [:html {:margin 0 :padding 0}] + [:h1 {:margin 0 :padding 0}] + [:h2 {:margin 0 :padding 0}] + [:h3 {:margin 0 :padding 0}] + [:h4 {:margin 0 :padding 0}])) + +(def header-css + (css [:h1.project-name {:font-size "34px" + :display "inline"}] + [:h2.project-version {:font-size "18px" + :margin-top 0 + :display "inline" + :margin-left "10px"}] + [:.toc-link {:font-size "12px" + :margin-left "10px" + :color "#252519" + :text-decoration "none"}] + [:.toc-link:hover {:color "#5050A6"}] + [:.toc :h1 {:font-size "34px" + :margin 0}] + [:.docs-header {:border-bottom "dotted #aaa 1px" + :padding-bottom "10px" + :margin-bottom "25px"}] + [:.toc :h1 {:font-size "24px"}] + [:.toc {:border-bottom "solid #bbb 1px" + :margin-bottom "40px"}] + [:.toc :ul {:margin-left "20px" + :padding-left "0px" + :padding-top 0 + :margin-top 0}] + [:.toc :li {:list-style-type "none" + :padding-left 0}] + [:.dependencies {}] + [:.dependencies :table {:font-size "16px" + :width "99.99%" + :border "none" + :margin-left "20px"}] + [:.dependencies :td {:padding-right "20px;" + :white-space "nowrap"}] + [:.dependencies :.dotted {:width "99%"}] + [:.dependencies :.dotted :hr {:height 0 + :noshade "noshade" + :color "transparent" + :background-color "transparent" + :border-bottom "dotted #bbb 1px" + :border-top "none" + :border-left "none" + :border-right "none" + :margin-bottom "-6px"}] + [:.dependencies :.dep-version {:text-align "right"}] + [:.header :p {:margin-left "20px"}])) + +(def floating-toc-css + (css [:#floating-toc {:position "fixed" + :top "10px" + :right "20px" + :height "20px" + :overflow "hidden" + :text-align "right"}] + [:#floating-toc :li {:list-style-type "none" + :margin 0 + :padding 0}])) + +(def general-css + (css + [:body {:margin 0 + :padding 0 + :font-family "'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;" + :font-size "16px" + :color "#252519"}] + [:h1 {:font-size "20px" + :margin-top 0}] + [:.anchor {:text-decoration "none" + :color "#252519"}] + [:.anchor:hover {:color "#5050A6"}] + [:table {:border-spacing 0 + :border-bottom "solid #ddd 1px;" + :margin-bottom "10px"}] + [:code {:display "inline"}] + [:p {:margin-top "8px"}] + [:tr {:margin "0px" + :padding "0px"}] + [:td.docs {:width "45%" + :vertical-align "top" + :margin "0px" + :padding-left "55px" + :padding-right "20px" + :border "none"}] + [:td.codes {:width "55%" + :background-color "#F5F5FF" + :vertical-align "top" + :margin "0px" + :padding-left "20px" + :border "none" + :overflow "hidden" + :font-size "10pt" + :border-left "solid #ddd 1px"}] + [:td.spacer {:padding-bottom "40px"}] + [:.footer {:text-align "center"}])) + (defn page-template [header toc floating-toc content] "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 @@ -189,103 +290,14 @@ (inline-js "xregexp-min.js") (inline-js "shCore.js") (inline-js "shBrushClojure.js") - #_ (inline-js "app.js") - [:script {:type "text/javascript" :src "./../resources/app.js"}] + (inline-js "app.js") + #_[:script {:type "text/javascript" :src "./../resources/app.js"}] (inline-css "shCore.css") (inline-css "shThemeEclipse.css") - (css - [:html {:margin 0 :padding 0}] - [:h1 {:margin 0 :padding 0}] - [:h2 {:margin 0 :padding 0}] - [:h3 {:margin 0 :padding 0}] - [:h4 {:margin 0 :padding 0}] - - [:body {:margin 0 - :padding 0 - :font-family "'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;" - :font-size "16px" - :color "#252519"}] - [:.toc-link {:font-size "12px" - :margin-left "10px" - :color "#252519" - :text-decoration "none"}] - [:.toc-link:hover {:color "#5050A6"}] - [:.docs-header {:border-bottom "dotted #aaa 1px" - :padding-bottom "10px" - :margin-bottom "25px"}] - [:.anchor {:text-decoration "none" - :color "#252519"}] - [:.anchor:hover {:color "#5050A6"}] - [:.toc :h1 {:font-size "34px" - :margin 0}] - [:h1 {:font-size "20px" - :margin-top 0}] - [:h1.project-name {:font-size "34px" - :display "inline"}] - [:h2.project-version {:font-size "18px" - :margin-top 0 - :display "inline" - :margin-left "10px"}] - [:table {:border-spacing 0 - :border-bottom "solid #ddd 1px;" - :margin-bottom "10px"}] - [:code {:display "inline"}] - [:p {:margin-top "8px"}] - [:tr {:margin "0px" - :padding "0px"}] - [:td.docs {:width "45%" - :vertical-align "top" - :margin "0px" - :padding-left "55px" - :padding-right "20px" - :border "none"}] - [:td.codes {:width "55%" - :background-color "#F5F5FF" - :vertical-align "top" - :margin "0px" - :padding-left "20px" - :border "none" - :overflow "hidden" - :font-size "10pt" - :border-left "solid #ddd 1px"}] - [:td.spacer {:padding-bottom "40px"}] - [:.toc :h1 {:font-size "24px"}] - [:.toc {:border-bottom "solid #bbb 1px" - :margin-bottom "40px"}] - [:.toc :ul {:margin-left "20px" - :padding-left "0px" - :padding-top 0 - :margin-top 0}] - [:.toc :li {:list-style-type "none" - :padding-left 0}] - [:.footer {:text-align "center"}] - [:#floating-toc {:position "fixed" - :top "10px" - :right "20px" - :height "20px" - :overflow "hidden"}] - [:#floating-toc :li {:list-style-type "none" - :margin 0 - :padding 0}] - [:.dependencies {}] - [:.dependencies :table {:font-size "16px" - :width "99.99%" - :border "none" - :margin-left "20px"}] - [:.dependencies :td {:padding-right "20px;" - :white-space "nowrap"}] - [:.dependencies :.dotted {:width "99%"}] - [:.dependencies :.dotted :hr {:height 0 - :noshade "noshade" - :color "transparent" - :background-color "transparent" - :border-bottom "dotted #bbb 1px" - :border-top "none" - :border-left "none" - :border-right "none" - :margin-bottom "-6px"}] - [:.dependencies :.dep-version {:text-align "right"}] - [:.header :p {:margin-left "20px"}]) + reset-css + header-css + floating-toc-css + general-css [:title "Marginalia Output"]] [:body [:table @@ -305,9 +317,6 @@ SyntaxHighlighter.all()"]]])) - - - ;; Syntax highlighting is done a bit differently than docco. Instead of embedding ;; the higlighting metadata on the parse / html gen phase, we use [SyntaxHighlighter](http://alexgorbatchev.com/SyntaxHighlighter/) ;; to do it in javascript.