Inch
A documentation analysis tool for the Ruby language
Install / Use
/learn @rrrene/InchREADME
Inch

inch gives you hints where to improve your docs. One Inch at a time.
Take a look at the project page with screenshots (live and in full color).
What can it do?
inch is a little bit like Code Climate, but for your inline code documentation (and not a webservice).
It is a command-line utility that suggests places in your codebase where documentation can be improved.
If there are no inline-docs yet, inch can tell you where to start.
Installation
Add this line to your application's Gemfile:
gem 'inch', require: false
And then execute:
$ bundle
Or install it yourself as:
$ gem install inch
Usage
To run Inch, simply type
$ inch
Given a lib directory with the following code inside:
class Foo
# A complicated method
def complicated(o, i, *args, &block)
# ... snip ...
end
# An example of a method that takes a parameter (+param1+)
# and does nothing.
#
# Returns nil
def nothing(param1)
end
def filename
"#{self.class}_#{id}.foo"
end
end
Inch will suggest that the docs could be improved:
# Properly documented, could be improved:
┃ B ↑ Foo#complicated
# Undocumented:
┃ U ↑ Foo
┃ U ↗ Foo#filename
You might want to look at these files:
┃ lib/foo.rb
Grade distribution (undocumented, C, B, A): █ ▁ ▄ ▄
Only considering priority objects: ↑ ↗ → (use `--help` for options).
Configuration
By default, Inch looks into {app,lib}/**/*.rb for Ruby source files. You can customize this by either passing the desired files to the executable:
$ inch suggest plugins/**/*.rb
or by creating a file named .inch.yml in your project directory:
files:
# define files included in the analysis (defaults to ["{app,lib}/**/*.rb"])
included:
- plugins/**/*.rb
# define files excluded from the analysis (defaults to [])
excluded:
# you can use file paths
- plugins/vendor/sparkr/sparkr.rb
# or globs
- plugins/vendor/**/*.rb
# or regular expressions
- !ruby/regexp /vendor/
As you would expect, included sets an array of included files (or globs) and excluded sets an array of files, globs or regexes of files to exclude from the evaluation.
Philosophy
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.
- It does not aim for "fully documented" or "100% documentation coverage".
- It does not tell you to document all your code (neither does it tell you not to).
- It does not impose rules on how your documentation should look like.
- It does not require that, e.g."every method's documentation should be a single line under 80 characters not ending in a period" or that "every class and module should provide a code example of their usage".
Inch takes a more relaxed approach towards documentation measurement and tries to show you places where your codebase could use more documentation.
The Grade System
Inch assigns grades to each class, module, constant or method 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- Undocumented
Using this system has some advantages compared to plain coverage scores:
- You can get an
Aeven if you "only" get 90 out of 100 possible points. - Getting a
Bis basically good enough. - Undocumented objects are assigned a special grade, instead of scoring 0%.
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.
Priorities ↑ ↓
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
- it is more important to document public methods than private ones
- it is more important to document methods with many parameters than methods without parameters
- it is not important to document objects marked as
:nodoc:
Priorities are displayed as arrows. Arrows pointing north mark high priority objects, arrows pointing south mark low priority objects.
No overall scores or grades
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:
- There is a significant amount of documentation present.
- The present documentation seems good.
- There are still undocumented methods.
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.
Features
Inch is built to parse YARD, RDoc and TomDoc style documentation comments, but works reasonably well with unstructured comments.
These inline-docs below all score an A despite being written in different styles:
# Detects the size of the blob.
#
# @example
# blob_size(filename, blob) # => some value
#
# @param filename [String] the filename
# @param blob [String] the blob data
# @param mode [String, nil] optional String mode
# @return [Fixnum,nil]
def blob_size(filename, blob, mode = nil)
# Detects the size of the blob.
#
# blob_size(filename, blob) # => some value
#
# Params:
# +filename+:: String filename
# +blob+:: String blob data
# +mode+:: Optional String mode (defaults to nil)
def blob_size(filename, blob, mode = nil)
# Public: Detects the size of the blob.
#
# filename - String filename
# blob - String blob data
# mode - Optional String mode (defaults to nil)
#
# Examples
#
# blob_size(filename, blob)
# # => some value
#
# Returns Fixnum or nil.
def blob_size(filename, blob, mode = nil)
But you don't have to adhere to any specific syntax. This gets an A as well:
# Returns the size of a +blob+ for a given +filename+.
#
# blob_size(filename, blob)
# # => some value
#
def blob_size(filename, blob, mode = nil)
Inch let's you write your documentation the way you want.
Subcommands
It comes with four sub-commands: suggest, stats, show, and list
inch suggest
Suggests places where a codebase suffers a lack of documentation. The command line exit status will be above zero when suggestions are found.
$ inch suggest
# Properly documented, could be improved:
┃ B ↑ Inch::CLI::Command::BaseList#prepare_list
┃ B ↑ Inch::CodeObject::Ruby::MethodParameterObject#initialize
┃ B ↗ Inch::CLI::Command::Stats#run
┃ B ↗ Inch::CLI::CommandParser#run
# Not properly documented:
┃ C ↑ Inch::CodeObject::NodocHelper#implicit_nodoc_comment?
┃ C ↑ Inch::CLI::Command::Output::Suggest#initialize
┃ C ↑ Inch::Rake::Suggest#initialize
# Undocumented:
┃ U ↑ Inch::Evaluation::ConstantObject#evaluate
┃ U ↑ Inch::Evaluation::MethodObject#evaluate
┃ U ↑ Inch::SourceParser#find_object
You might want to look at these files:
┃ lib/inch/code_object/proxy/base.rb
┃ lib/inch/code_object/proxy/method_object.rb
┃ lib/inch/evaluation/role/object.rb
Grade distribution (undocumented, C, B, A): █ ▃ ▁ ▄
Only considering priority objects: ↑ ↗ → (use `--help` for options).
inch stats
Shows you an overview of the codebase.
$ inch stats
Grade distribution: (undocumented, C, B, A)
Overall: █ ▂ ▁ ▃ 439 objects
Grade distribution by priority:
↑ ▁ ▄ █ ▁ 10 objects
↗ █ ▃ ▁ ▃ 302 objects
→ ▆ ▂ ▁ █ 73 objects
↘ █ ▁ ▁ ▁ 54 objects
↓ ▁ ▁ ▁ ▁ 0 objects
Priority distribution in grades: (low to high)
↓ ↘ → ↗ ↑
U: ▁ ▁ ▁ ▁ ▁ ▁ ▂ ▂ ▁ █ ▁ ▁ ▁ ▁ ▁ 243 objects
C: ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ █ ▁ ▁ ▁ ▁ ▁ 73 objects
B: ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ █ ▂ ▄ ▁ ▁ ▁ 19 objects
A: ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▄ ▁ █ ▁ ▁ ▁ ▁ ▁ 104 objects
Try `--format json|yaml` for raw numbers.
inch show
Shows you details about what can be improved in a specific object.
$ inch show Inch::SourceParser#find_object
# Inch::SourceParser#find_object
┃ -> lib/inch/source_parser.rb:16
┃ ------------------------------------------------------
┃ Grade: C - Needs work
┃ ------------------------------------------------------
┃ + Add a comment describing the method
┃ + Describe the parameter 'path'
┃ + Describe the return type of 'find_object'
┃ + Add a code example (optional)
┃ ------------------------------------------------------
inch list
Lists all objects in your codebase with their grades.
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
