From df7ddcbc286a65ee2bc61e01150e0753a9a3db65 Mon Sep 17 00:00:00 2001 From: Martin Klepsch Date: Wed, 15 Aug 2018 21:42:20 +0200 Subject: [PATCH 1/8] Trust cljs analyzer to read macros correctly Author: @martinklepsch Codox previously did two passes to also read macros for ClojureScript. This is actually no longer necessary with more recent versions of ClojureScript. https://github.com/cljdoc/codox/commit/3079986bd9500c62775f795ec92b30a7aeb742c9 --- codox/src/codox/main.clj | 23 ++--------------------- codox/src/codox/reader/clojurescript.clj | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/codox/src/codox/main.clj b/codox/src/codox/main.clj index 1a11ab30..ed9ae6b0 100644 --- a/codox/src/codox/main.clj +++ b/codox/src/codox/main.clj @@ -4,6 +4,7 @@ (:require [clojure.string :as str] [clojure.java.shell :as shell] [codox.reader.clojure :as clj] + [codox.reader.clojurescript :as cljs] [codox.reader.plaintext :as text])) (defn- writer [{:keys [writer]}] @@ -19,29 +20,9 @@ (throw (Exception. (str "Could not resolve codox writer " writer-sym)))))) -(defn- macro? [var] - (= (:type var) :macro)) - -(defn- read-macro-namespaces [paths read-opts] - (->> (clj/read-namespaces paths read-opts) - (map (fn [ns] (update-in ns [:publics] #(filter macro? %)))) - (remove (comp empty? :publics)))) - -(defn- merge-namespaces [namespaces] - (for [[name namespaces] (group-by :name namespaces)] - (assoc (first namespaces) :publics (mapcat :publics namespaces)))) - -(defn- cljs-read-namespaces [paths read-opts] - ;; require is here to allow Clojure 1.3 and 1.4 when not using ClojureScript - (require 'codox.reader.clojurescript) - (let [reader (find-var 'codox.reader.clojurescript/read-namespaces)] - (merge-namespaces - (concat (reader paths read-opts) - (read-macro-namespaces paths read-opts))))) - (def ^:private namespace-readers {:clojure clj/read-namespaces - :clojurescript cljs-read-namespaces}) + :clojurescript cljs/read-namespaces}) (defn- var-symbol [namespace var] (symbol (name (:name namespace)) (name (:name var)))) diff --git a/codox/src/codox/reader/clojurescript.clj b/codox/src/codox/reader/clojurescript.clj index dee1892c..254d8e77 100644 --- a/codox/src/codox/reader/clojurescript.clj +++ b/codox/src/codox/reader/clojurescript.clj @@ -50,15 +50,16 @@ :else :var)) (defn- read-var [file vars var] - (-> var - (select-keys [:name :line :arglists :doc :dynamic :added :deprecated :doc/format]) - (update-some :name (comp symbol name)) - (update-some :arglists remove-quote) - (update-some :doc correct-indent) - (assoc-some :file (.getPath file) - :type (var-type var) - :members (map (partial read-var file vars) - (protocol-methods var vars))))) + (let [vt (var-type var)] + (-> var + (select-keys [:name :line :arglists :doc :dynamic :added :deprecated :doc/format]) + (update-some :name (comp symbol name)) + (update-some :arglists remove-quote) + (update-some :doc correct-indent) + (assoc-some :file (if (= vt :macro) (:file var) (.getPath file)) + :type vt + :members (map (partial read-var file vars) + (protocol-methods var vars)))))) (defn- read-publics [state namespace file] (let [vars (vals (ana/ns-publics state namespace))] From 370ef9ec9883ff64b14fd196b98d154e5403392b Mon Sep 17 00:00:00 2001 From: Martin Klepsch Date: Tue, 28 Aug 2018 18:20:32 +0200 Subject: [PATCH 2/8] Check for `seq?` instead of `list?` when removing `'quote` from arglists Author: @martinklepsch For some reason the list? check wasn't enough to remove 'quote and I ended up with 'quote in arglists. seq? did the trick (and might be more appropriate anyways?). https://github.com/cljdoc/codox/commit/25b01ae5c471bd4d1ef4290d7724d6878157f31d --- codox/src/codox/reader/clojurescript.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codox/src/codox/reader/clojurescript.clj b/codox/src/codox/reader/clojurescript.clj index 254d8e77..45990705 100644 --- a/codox/src/codox/reader/clojurescript.clj +++ b/codox/src/codox/reader/clojurescript.clj @@ -15,7 +15,7 @@ (-> file .getName cljs-filename?))) (defn- remove-quote [x] - (if (and (list? x) (= (first x) 'quote)) + (if (and (seq? x) (= (first x) 'quote)) (second x) x)) From ebfece3070287ebcb5ff0d7392dc964d7f92f4dd Mon Sep 17 00:00:00 2001 From: Martin Klepsch Date: Fri, 9 Nov 2018 19:01:42 +0100 Subject: [PATCH 3/8] Fix analysis issues with cljs 1.10.439 Author: @martinklepsch I noticed some issues (+ more details[2]) with the new CLJS version. Turns out setting *analyze-deps* to false was never really supported for macro-containing namespaces and we just got lucky[3]. Fixes [1] [1] https://github.com/cljdoc/cljdoc/issues/201 [2] https://gist.github.com/martinklepsch/9f885feb061ec3f03f365e22d0d9bf5b [3] https://clojurians-log.clojureverse.org/cljs-dev/2018-11-09/1541786231.245300 https://github.com/cljdoc/codox/commit/e0cd26910704c416611fc81f43f890a26861c221 --- codox/src/codox/reader/clojurescript.clj | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/codox/src/codox/reader/clojurescript.clj b/codox/src/codox/reader/clojurescript.clj index 45990705..1db1296f 100644 --- a/codox/src/codox/reader/clojurescript.clj +++ b/codox/src/codox/reader/clojurescript.clj @@ -4,6 +4,8 @@ (:require [clojure.java.io :as io] [cljs.analyzer :as an] [cljs.analyzer.api :as ana] + [cljs.closure] + [cljs.env] [clojure.string :as str])) (defn- cljs-filename? [filename] @@ -71,10 +73,11 @@ (sort-by (comp str/lower-case :name))))) (defn- analyze-file [file] - (let [state (ana/empty-state)] - (binding [an/*analyze-deps* false] - (ana/no-warn - (ana/analyze-file state file {}))) + (let [opts (cljs.closure/add-implicit-options {}) + state (cljs.env/default-compiler-env opts)] + (ana/no-warn + (cljs.closure/validate-opts opts) + (ana/analyze-file state file opts)) state)) (defn- read-file [path file exception-handler] From 492837fa168bcdd4d6129171b8b91d698a89f32d Mon Sep 17 00:00:00 2001 From: Martin Klepsch Date: Thu, 18 Oct 2018 11:18:49 +0200 Subject: [PATCH 4/8] Fix duplicate namespaces Author: @martinklepsch When there are multiple files (e.g. .clj and .cljc) for a namespace Codox would analyse those namespaces twice returning the analysis result twice as well. https://github.com/cljdoc/codox/commit/3f2ea84ae5e27e6f527b38bbc8d8fcecc24fe47f https://github.com/cljdoc/cljdoc/issues/155 --- codox/src/codox/reader/clojure.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codox/src/codox/reader/clojure.clj b/codox/src/codox/reader/clojure.clj index f37346c0..119f2e80 100644 --- a/codox/src/codox/reader/clojure.clj +++ b/codox/src/codox/reader/clojure.clj @@ -116,8 +116,8 @@ (defn- find-namespaces [file] (cond - (.isDirectory file) (ns/find-namespaces-in-dir file) - (jar-file? file) (ns/find-namespaces-in-jarfile (JarFile. file)))) + (.isDirectory file) (set (ns/find-namespaces-in-dir file)) + (jar-file? file) (set (ns/find-namespaces-in-jarfile (JarFile. file))))) (defn read-namespaces "Read Clojure namespaces from a set of source directories (defaults From 732ddaad7a2b1c844a7514d2951d302e400c12ff Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Mon, 3 Jul 2023 16:23:28 +0200 Subject: [PATCH 5/8] Add support for `{:language :both}` option Author: @ptaoussanis - This implementation attempts to be minimally invasive. Most of the logical changes are within `html/write-index` and `html/write-namespaces`, where a special path is introduced for "cross-platform" projects (= language `:both`). - NO behavioural changes are intended for traditional (non-cross-platform) projects. - See #216 for detailed feature discussion. --- .../codox/theme/default/css/default.css | 25 +++- codox/src/codox/main.clj | 25 +++- codox/src/codox/writer/html.clj | 137 ++++++++++++++---- 3 files changed, 153 insertions(+), 34 deletions(-) diff --git a/codox/resources/codox/theme/default/css/default.css b/codox/resources/codox/theme/default/css/default.css index 33f78fed..241ec121 100644 --- a/codox/resources/codox/theme/default/css/default.css +++ b/codox/resources/codox/theme/default/css/default.css @@ -44,7 +44,7 @@ h5.license { right: 0; height: 22px; color: #f5f5f5; - padding: 5px 7px; + padding: 7px 10px; } #content { @@ -97,6 +97,8 @@ h5.license { } #header h1 { + display: block; + float: left; margin: 0; padding: 0; font-size: 18px; @@ -121,6 +123,27 @@ h5.license { color: #f5f5f5; } +#langs { + display: block; + float: left; + font-size: 16px; + margin: 0 10px; + font-weight: lighter; +} + +#langs .lang { + display: inline-block; + margin: 0 2px; + padding: 0 7px; + background-color: #bbb; + border-radius: 6px; + vertical-align: middle; +} + +#langs .lang.current { + background-color: #a33; +} + .sidebar a { color: #333; } diff --git a/codox/src/codox/main.clj b/codox/src/codox/main.clj index ed9ae6b0..dd429bfa 100644 --- a/codox/src/codox/main.clj +++ b/codox/src/codox/main.clj @@ -58,14 +58,24 @@ (filter #(some (partial ns-matches? %) ns-filters) namespaces) namespaces)) +(defn- cross-platform? + "Do given options indicate *both* Clojure and ClojureScript sources?" + [{:keys [language] :as opts}] + (= language :both)) + (defn- read-namespaces + "Returns { } for cross-platform opts, + or otherwise." [{:keys [language root-path source-paths namespaces metadata exclude-vars] :as opts}] - (let [reader (namespace-readers language)] - (-> (reader source-paths (select-keys opts [:exception-handler])) - (filter-namespaces namespaces) - (remove-excluded-vars exclude-vars) - (add-source-paths root-path source-paths) - (add-ns-defaults metadata)))) + (if (cross-platform? opts) + {:clojure (read-namespaces (assoc opts :language :clojure)) + :clojurescript (read-namespaces (assoc opts :language :clojurescript))} + (let [reader (namespace-readers language)] + (-> (reader source-paths (select-keys opts [:exception-handler])) + (filter-namespaces namespaces) + (remove-excluded-vars exclude-vars) + (add-source-paths root-path source-paths) + (add-ns-defaults metadata))))) (defn- read-documents [{:keys [doc-paths doc-files] :or {doc-files :all}}] (cond @@ -105,4 +115,5 @@ documents (read-documents options)] (write-fn (assoc options :namespaces namespaces - :documents documents))))) + :documents documents + :cross-platform? (cross-platform? options)))))) diff --git a/codox/src/codox/writer/html.clj b/codox/src/codox/writer/html.clj index 0a4f9c81..b27214dd 100644 --- a/codox/src/codox/writer/html.clj +++ b/codox/src/codox/writer/html.clj @@ -146,8 +146,18 @@ (if-let [doc (:doc metadata)] (markdown-to-html doc project ns))]) +(defn- language-fileext + [language] + (case language + :clojure ".clj" + :clojurescript ".cljs" + nil "")) + +(defn- index-filename [language] + (str "index" (language-fileext language) ".html")) + (defn- ns-filename [namespace] - (str (:name namespace) ".html")) + (str (:name namespace) (language-fileext (:language namespace)) ".html")) (defn- ns-filepath [output-dir namespace] (str output-dir "/" (ns-filename namespace))) @@ -235,11 +245,12 @@ [:span.bottom]]))) (defn- index-link [project on-index?] - (list - [:h3.no-link [:span.inner "Project"]] - [:ul.index-link - [:li.depth-1 {:class (if on-index? "current")} - (link-to "index.html" [:div.inner "Index"])]])) + (when-not (:cross-platform? project) + (list + [:h3.no-link [:span.inner "Project"]] + [:ul.index-link + [:li.depth-1 {:class (if on-index? "current")} + (link-to "index.html" [:div.inner "Index"])]]))) (defn- topics-menu [project current-doc] (if-let [docs (seq (:documents project))] @@ -275,16 +286,26 @@ (get-in project [:html :namespace-list] default))) (defn- namespaces-menu [project current-ns] - (let [namespaces (:namespaces project)] + (when (:show-namespaces? project) + (let [namespaces (:namespaces project)] + (list + [:h3.no-link [:span.inner "Namespaces"]] + (case (namespace-list-type project) + :flat (flat-namespaces namespaces current-ns) + :nested (nested-namespaces namespaces current-ns)))))) + +(defn- platforms-menu [project] + (when (:show-platforms? project) (list - [:h3.no-link [:span.inner "Namespaces"]] - (case (namespace-list-type project) - :flat (flat-namespaces namespaces current-ns) - :nested (nested-namespaces namespaces current-ns))))) + [:h3.no-link [:span.inner "Platforms"]] + [:ul.index-link + [:li.depth-1 (link-to (index-filename :clojure) [:div.inner "Clojure"])] + [:li.depth-1 (link-to (index-filename :clojure) [:div.inner "ClojureScript"])]]))) (defn- primary-sidebar [project & [current]] [:div.sidebar.primary (index-link project (nil? current)) + (platforms-menu project) (topics-menu project current) (namespaces-menu project current)]) @@ -314,10 +335,23 @@ [:span.project-name (h (:name project))] " " [:span.project-version (h (:version project))]]) +(defn- header-platforms [project] + (when (:cross-platform? project) + (let [{:keys [language]} project] + [:div#langs + (if (= language :clojure) + [:div.lang.current "clj"] + [:div.lang (link-to (index-filename :clojure) "clj")]) + + (if (= language :clojurescript) + [:div.lang.current "cljs"] + [:div.lang (link-to (index-filename :clojurescript) "cljs")])]))) + (defn- header [project] [:div#header [:h2 "Generated by " (link-to "https://github.com/weavejester/codox" "Codox")] - [:h1 (link-to "index.html" (project-title project))]]) + [:h1 (link-to "index.html" (project-title project))] + (header-platforms project)]) (defn- package [project] (if-let [p (:package project)] @@ -360,16 +394,28 @@ [:ul.topics (for [doc docs] [:li (link-to (doc-filename doc) (h (:title doc)))])])) - [:h2 "Namespaces"] - (for [namespace (sort-by :name (:namespaces project))] - [:div.namespace - [:h3 (link-to (ns-filename namespace) (h (:name namespace)))] - [:div.doc (format-docstring project nil (update-in namespace [:doc] util/summary))] - [:div.index - [:p "Public variables and functions:"] - (unordered-list - (for [var (sorted-public-vars namespace)] - (list " " (link-to (var-uri namespace var) (h (:name var))) " ")))]])]])) + + (when (:show-platforms? project) + (list + [:h2 "Platforms"] + [:p "This project includes both Clojure and ClojureScript code, please " + [:strong "choose a platform"] " to view its documentation:"] + [:ul + [:li (link-to (index-filename :clojure) "Clojure")] + [:li (link-to (index-filename :clojurescript) "ClojureScript")]])) + + (when (:show-namespaces? project) + (list + [:h2 "Namespaces"] + (for [namespace (sort-by :name (:namespaces project))] + [:div.namespace + [:h3 (link-to (ns-filename namespace) (h (:name namespace)))] + [:div.doc (format-docstring project nil (update-in namespace [:doc] util/summary))] + [:div.index + [:p "Public variables and functions:"] + (unordered-list + (for [var (sorted-public-vars namespace)] + (list " " (link-to (var-uri namespace var) (h (:name var))) " ")))]])))]])) (defmulti format-document "Format a document into HTML." @@ -465,12 +511,51 @@ (.mkdirs (io/file output-dir dir)))) (defn- write-index [output-dir project] - (spit (io/file output-dir "index.html") (transform-html project (index-page project)))) + (let [{:keys [namespaces cross-platform?]} project] + + (when cross-platform? + ;; Write an index file for each language + (doseq [language (keys namespaces)] + (let [namespaces (map #(assoc % :language language) (get namespaces language)) + project + (assoc project + :namespaces namespaces + :language language + :show-platforms? false + :show-namespaces? true)] + (spit (io/file output-dir (index-filename language)) + (transform-html project (index-page project)))))) + + ;; Always write a main index file + (let [project (assoc project + :show-platforms? cross-platform? + :show-namespaces? (not cross-platform?))] + (spit (io/file output-dir (index-filename nil)) + (transform-html project (index-page project)))))) (defn- write-namespaces [output-dir project] - (doseq [namespace (:namespaces project)] - (spit (ns-filepath output-dir namespace) - (transform-html project (namespace-page project namespace))))) + (let [{:keys [namespaces cross-platform?]} project] + + (if cross-platform? + ;; Write namespace files for each language + (doseq [language (keys namespaces)] + (let [namespaces (map #(assoc % :language language) (get namespaces language))] + (doseq [namespace namespaces] + (let [project (assoc project + :namespaces namespaces + :language language + :show-platforms? false + :show-namespaces? true)] + (spit (ns-filepath output-dir namespace) + (transform-html project (namespace-page project namespace))))))) + + ;; Write namespace files for only language + (doseq [namespace namespaces] + (let [project (assoc project + :show-platforms? false + :show-namespaces? true)] + (spit (ns-filepath output-dir namespace) + (transform-html project (namespace-page project namespace)))))))) (defn- write-documents [output-dir project] (doseq [document (:documents project)] From ce96de8102ffb9fbdf4a57600b6c3b4e8e0cc4e1 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 4 Jul 2023 18:45:56 +0200 Subject: [PATCH 6/8] Add support for advanced `:base-language` option Author: @ptaoussanis This is an advanced option to help prevent any broken doc links when upgrading a project's docs from single language to dual language. In this case, :base-language can be set to the previous (single) language for which doc links may already exist in the wild. In detail, if {:language :both} then: {:base-language nil} => ".clj", ".cljs" file extensions {:base-language :clojure} => nil, ".cljs" file extensions {:base-language :clojurescript} => ".clj", nil file extensions For example: Library Foo previously used {:language :clojure} (either because it was Clojure only, or because of limitations in Codox). Various links to Foo's Codox documentation now exist in the wild. Foo's authors want to change to {:language :both}, but don't want to break pre-existing links in the wild. In this case, Foo's authors can use the following opts: {:language :both :base-language :clojure} This will produce files like the following: com.foolib.html ; For Clojure platform com.foolib.cljs.html ; For ClojureScript platform Any pre-existing links will successfully point to the same (Clojure) docs they did previously. --- codox/src/codox/writer/html.clj | 35 +++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/codox/src/codox/writer/html.clj b/codox/src/codox/writer/html.clj index b27214dd..e80c43d9 100644 --- a/codox/src/codox/writer/html.clj +++ b/codox/src/codox/writer/html.clj @@ -147,17 +147,26 @@ (markdown-to-html doc project ns))]) (defn- language-fileext - [language] - (case language - :clojure ".clj" - :clojurescript ".cljs" - nil "")) + ([language] + (case language + :clojure ".clj" + :clojurescript ".cljs" + nil "")) + ([language base-language] + (when (not= language base-language) + (language-fileext language)))) (defn- index-filename [language] (str "index" (language-fileext language) ".html")) (defn- ns-filename [namespace] - (str (:name namespace) (language-fileext (:language namespace)) ".html")) + (str (:name namespace) + (language-fileext (:language namespace) (:base-language namespace)) + ".html")) + +(comment + (ns-filename {:name 'my-ns :language :clojure}) + (ns-filename {:name 'my-ns :language :clojure :base-language :clojure})) (defn- ns-filepath [output-dir namespace] (str output-dir "/" (ns-filename namespace))) @@ -510,13 +519,22 @@ (doseq [dir dirs] (.mkdirs (io/file output-dir dir)))) +(defn- cross-platform-namespaces + [namespaces language base-language] + (map + #(assoc % + :language language + :base-language base-language) + (get namespaces language))) + (defn- write-index [output-dir project] (let [{:keys [namespaces cross-platform?]} project] (when cross-platform? ;; Write an index file for each language (doseq [language (keys namespaces)] - (let [namespaces (map #(assoc % :language language) (get namespaces language)) + (let [namespaces (cross-platform-namespaces namespaces language + (:base-language project)) project (assoc project :namespaces namespaces @@ -539,7 +557,8 @@ (if cross-platform? ;; Write namespace files for each language (doseq [language (keys namespaces)] - (let [namespaces (map #(assoc % :language language) (get namespaces language))] + (let [namespaces (cross-platform-namespaces namespaces language + (:base-language project))] (doseq [namespace namespaces] (let [project (assoc project :namespaces namespaces From 0906e860e1b3101ea149c3b2f8f1c3854b718d54 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 4 Jul 2023 13:56:17 +0200 Subject: [PATCH 7/8] Add linked platform labels ("clj", "cljs") to var docs Author: @ptaoussanis Note that this commit introduces new classes to `default.css` used (only) by "cross-platform" projects. This means: - NO behavioural changes are intended for non-cross-platform projects. - Cross-platform projects WILL require a theme that includes the new CSS classes. --- .../codox/theme/default/css/default.css | 19 ++++++++++-- codox/src/codox/main.clj | 29 ++++++++++++++++++- codox/src/codox/writer/html.clj | 18 ++++++++++++ 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/codox/resources/codox/theme/default/css/default.css b/codox/resources/codox/theme/default/css/default.css index 241ec121..446b6642 100644 --- a/codox/resources/codox/theme/default/css/default.css +++ b/codox/resources/codox/theme/default/css/default.css @@ -348,7 +348,8 @@ h5.license { h4.type, h4.dynamic, h4.added, -h4.deprecated { +h4.deprecated, +h4.lang { float: left; margin: 3px 10px 15px 0; font-size: 15px; @@ -359,7 +360,8 @@ h4.deprecated { .public h4.type, .public h4.dynamic, .public h4.added, -.public h4.deprecated { +.public h4.deprecated, +.public h4.lang { font-size: 13px; font-weight: bold; margin: 3px 0 0 10px; @@ -367,7 +369,8 @@ h4.deprecated { .members h4.type, .members h4.added, -.members h4.deprecated { +.members h4.deprecated, +.members h4.lang { margin-top: 1px; } @@ -387,6 +390,16 @@ h4.deprecated { color: #880000; } +.public h4.lang, .public h4.lang a { + font-weight: normal; + font-variant: normal; + color: #717171; +} + +.public h4.lang.current { + color: #a33; +} + .namespace { margin-bottom: 30px; } diff --git a/codox/src/codox/main.clj b/codox/src/codox/main.clj index dd429bfa..9f3cb953 100644 --- a/codox/src/codox/main.clj +++ b/codox/src/codox/main.clj @@ -77,6 +77,31 @@ (add-source-paths root-path source-paths) (add-ns-defaults metadata))))) +(defn- get-var-langs + "Returns { { }} for given namespaces." + ([language namespaces var-langs] + (reduce + (fn [var-langs ns] + (reduce + (fn [var-langs public-var] + (update-in var-langs [(:name ns) (:name public-var)] + #(conj (or % #{}) language))) + var-langs + (:publics ns))) + var-langs + namespaces)) + + ([options namespaces] + (if-not (cross-platform? options) + (get-var-langs (:language options) namespaces {}) + (->> + (get-var-langs :clojure (:clojure namespaces) {}) + (get-var-langs :clojurescript (:clojurescript namespaces)))))) + +(comment (get-var-langs {:language :clojure} + '({:name codox.main :publics ({:name defaults} {:name bar})} + {:name codox.foo :publics ({:name bar})}))) + (defn- read-documents [{:keys [doc-paths doc-files] :or {doc-files :all}}] (cond (not= doc-files :all) (map text/read-file doc-files) @@ -112,8 +137,10 @@ (let [options (merge defaults options) write-fn (writer options) namespaces (read-namespaces options) - documents (read-documents options)] + documents (read-documents options) + var-langs (get-var-langs options namespaces)] (write-fn (assoc options :namespaces namespaces :documents documents + :var-langs var-langs :cross-platform? (cross-platform? options)))))) diff --git a/codox/src/codox/writer/html.clj b/codox/src/codox/writer/html.clj index e80c43d9..efad384d 100644 --- a/codox/src/codox/writer/html.clj +++ b/codox/src/codox/writer/html.clj @@ -480,6 +480,24 @@ [:h4.type (name (:type var))]) (if (:dynamic var) [:h4.dynamic "dynamic"]) + + (if (:cross-platform? project) + (let [languages (get-in project [:var-langs (:name namespace) (:name var)]) + has-clj? (contains? languages :clojure) + has-cljs? (contains? languages :clojurescript) + {:keys [language]} project] + + (list + (when has-clj? + (if (= language :clojurescript) + [:h4.lang (link-to (var-uri (assoc namespace :language :clojure) var) "clj")] + [:h4.lang.current "clj"])) + + (when has-cljs? + (if (= language :clojure) + [:h4.lang (link-to (var-uri (assoc namespace :language :clojurescript) var) "cljs")] + [:h4.lang.current "cljs"]))))) + (added-and-deprecated-docs var) (if (:type-sig var) [:div.type-sig From f5e4b62c1c0fef78cbd7b55fba15de42480bf33c Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Wed, 5 Jul 2023 12:27:48 +0200 Subject: [PATCH 8/8] Adjust default theme: remove CSS shadows Author: @ptaoussanis Small change that hopefully contributes to a more modern look --- codox/resources/codox/theme/default/css/default.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codox/resources/codox/theme/default/css/default.css b/codox/resources/codox/theme/default/css/default.css index 446b6642..b48c5cbc 100644 --- a/codox/resources/codox/theme/default/css/default.css +++ b/codox/resources/codox/theme/default/css/default.css @@ -92,7 +92,7 @@ h5.license { #header { background: #3f3f3f; - box-shadow: 0 0 8px rgba(0, 0, 0, 0.4); + border-bottom: 1px solid #cccccc; z-index: 100; } @@ -103,7 +103,6 @@ h5.license { padding: 0; font-size: 18px; font-weight: lighter; - text-shadow: -1px -1px 0px #333; } #header h1 .project-version {