jaunt-lang / jaunt

[ABANDONED] A jaunt away from Clojure
https://github.com/jaunt-lang/jaunt/issues/157
134 stars 6 forks source link

Support for out of line documentation #82

Open arrdem opened 8 years ago

arrdem commented 8 years ago

Clojure's style of inline string documentation while effective in simple cases falls pretty flat the instant that a user wants to have formatting (tables, markdown, what have you) or localization of documentation. Since we have clojure.repl/doc as the canonical interface for fetching documentation already and :doc is strictly an implementation detail maybe it makes sense to extend support for the :doc key in clojure.repl/find-doc so that :doc can map to a keyword naming a resolver of some sort, and clojure.repl/doc-resolver or some such would then be a multimethod mapping resolver keywords to functions of vars and namespaces which return documentation for these things.

The resolver :plaintext-file would probably be provided in the box, and would resolve for symbols /{locale}/{namespace}/{name}.txt, thus allowing Clojure to lift docstrings out of line or even package them into a separate jar as well as support multiple localizations. Users could add other resolution methods, say :markdown-file establishing similar mappings.

arrdem commented 8 years ago

This would likely require a minor extension to either namespaces or the defn macro so that the docstring part of a defn could also be a keyword naming the resolution method. This probably suggests that resolution methods could likewise be attached to namespaces, and that finding a resolver at the namespace level if neither docstring nor resolver is not provided at the var level would be a reasonable fallback.

arrdem commented 8 years ago

This also has the accidental effect of helping with the various complaints against Clojure's metadata loading. Docstrings were one of the first things on that chopping block, and lifting them out to separate files serves in part to reduce loaded code size.