Inch for Elixir provides a Mix task to give you hints where to improve your inline docs. One Inch at a time.
Inch CI is the corresponding web service that provides continuous coverage analysis for open source projects.
Inch for Elixir is a utility that suggests places in your codebase where documentation can be improved.
If there are no inline-docs yet, Inch for Elixir can tell you where to start.
Add Inch for Elixir as a dependency in your mix.exs
file.
defp deps do
[
{:inch_ex, github: "rrrene/inch_ex", only: [:dev, :test]}
]
end
After you are done, run this in your shell to fetch the new dependency:
$ mix deps.get
To run Inch, simply type
$ mix inch
and you will get something like the following:
$ mix inch
# Properly documented, could be improved:
┃ B ↑ Foo.complicated/5
# Undocumented:
┃ U ↑ Foo
┃ U ↗ Foo.filename/1
Grade distribution (undocumented, C, B, A): █ ▁ ▄ ▄
Inch was created to help people document their code, therefore it may be more important to look at what it does not do than at what it does.
Inch takes a more relaxed approach towards documentation measurement and tries to show you places where your codebase could use more documentation.
Inch assigns grades to each module, function, macro or callback in a codebase, based on how complete the docs are.
The grades are:
A
- Seems really goodB
- Properly documented, but could be improvedC
- Needs workU
- UndocumentedUsing this system has some advantages compared to plain coverage scores:
A
even if you "only" get 90 out of 100 possible points.B
is basically good enough.The last point might be the most important one: If objects are undocumented, there is nothing to evaluate. Therefore you can not simply give them a bad rating, because they might be left undocumented intentionally.
Every class, module, constant and method in a codebase is assigned a priority which reflects how important Inch thinks it is to be documented.
This process follows some reasonable rules, like
@doc false
Priorities are displayed as arrows. Arrows pointing north mark high priority objects, arrows pointing south mark low priority objects.
Inch does not give you a grade for your whole codebase.
"Why?" you might ask. Look at the example below:
Grade distribution (undocumented, C, B, A): ▄ ▁ ▄ █
In this example there is a part of code that is still undocumented, but the vast majority of code is rated A or B.
This tells you three things:
Inch does not really tell you what to do from here. It suggests objects and files that could be improved to get a better rating, but that is all. This way, it is perfectly reasonable to leave parts of your codebase undocumented.
Instead of reporting
coverage: 67.1% 46 ouf of 140 checks failed
and leaving you with a bad feeling, Inch tells you there are still undocumented objects without judging.
This provides a lot more insight than an overall grade could, because an overall grade for the above example would either be an A
(if the evaluation ignores undocumented objects) or a weak C
(if the evaluation includes them).
The grade distribution does a much better job of painting the bigger picture.
I will point you to the Inch for Ruby README for more information about the Inch project.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)René Föhring (@rrrene)
The first version of Inch for Elixir owed its existence to the extensive study and "code borrowing" from ExDoc.
Inch for Elixir is released under the MIT License. See the LICENSE file for further details.