Hi all,
Maybe it's a good idea at this point in the development of ex_doc to
take a step back and think about the nature of documentation what we
want to support.
My current line of thought is that documentation can be divided into
three categories:
1. Reference: That's just the stuff we have already. Very structured.
2. Guide: A set of chapters intended to be read in order like a manual.
Somewhat structured (chapter, section, etc).
3. Miscellaneous: All kinds of files with all kinds of information that
the user may want to know. For example: README, LICENCE, CONTRIBUTING.
Guide and Misc documentation are similar in that they're both likely to
be markdown files. Each project only has one guide however and probably
multiple Misc documentation files.
Reference documentation has a lot of structure so there's a lot to talk
about. ;) Let me just write down a few associations (note that functions
= functions + macros + callbacks):
* A module contains zero or more types.
* A module contains zero or more functions.
* A record contains two types (t() and option()) which are of not much
use to the user (hard to parse mentally).
* A record contains zero (one?) or more fields.
* A record doesn't contain any functions (though some do through hacks).
* A protocol contains one type (which is apparently all the supported
types), in any case it's not of much use to the user.
* A protocol contains one or more functions.
If we disregard types you can classify our entities into two categories:
modules (including record modules and protocol modules) and
fields/functions.
I've recently looked at yard (
http://www.yardoc.org, example:
http://rubydoc.info/gems/dm-core/1.1.0/frames). Yard is the inspiration
for ex_doc so it's not odd that yard and ex_doc look pretty much the
same. But there's a significant difference in the sidebar. yard has
"Classes | Fields | Files", ex_doc has "Modules | Records | Protocols".
Yard's fields list is simply a list of all methods and members from all
classes. So in yard the first two items are different views on the same
information whereas in ex_doc they are different pieces of information.
Lets think for a moment about the conceptual model of Elixir that exists
in a user's head. For a user the record ExDoc.ModuleNode lives in ExDoc.
The fact that it lives in ExDoc carries some meaning. The namespace
ExDoc means something independent of what functions are in the module ExDoc.
To the user what ex_doc calls modules, records and protocols all live in
one big tree, regardless of their representation. The current conceptual
model of ex_doc is that they are very different things. I believe this
mismatch causes decreased usability.
Let's take a look at different ways in which we could potentially
present information:
* Modules, records, protocols as a tree.
* Modules, records, protocols as a flattened list.
* Both but with only some of the types shown (filtering on module type).
* Both but with only things that match a certain name pattern.
* Both filtering on module type and name.
* Functions, macros and callbacks as a list (with their module in small
letters below them, like when you search for something).
* The list, but with only some of the types shown (filtering on member
type).
* The list but with only things that match a certain name pattern.
* Both filtering on member type and name.
The way I think of it we could incorporate all of these in ex_doc. We
already require Javascript, it should be possible to have both the tree
view and the flat view (have the tree data available to JS, flattening a
tree is easy).
In my mind the ideal ex_doc will have four main categories: Modules |
Functions/Fields (need a good name for that) | Guide | Files (Misc docs).
Within modules we'd have some toggle button like things: Modules (only)
| Records (only) | Protocols (only). These would choose what to filter.
The "(only)" would be a different button that would turn on the
corresponding button and turn off the others.
There would be an elegantly placed button somewhere to switch between
tree and flat form.
Types would not be included in this system (as they are not now), they
would be in the documentation and possibly some search system could find
them, but it's pretty rare that you search for types (especially
considering the autolinking that's in place).
I believe this would make ex_doc easier to use while not fundamentally
altering it.
Comments are very welcome. :)
Greetings,
Peter