This is a historical explainer written for this unofficial archive. Relish has closed, so nothing here describes a service you can still sign up for or use.
The default order problem
When a tool turns a directory into a documentation site, it has to pick an order. Without instructions, the obvious choice is alphabetical by filename. On Relish, publishers who wanted a different order used the .nav file described on a separate page of this archive. This page looks at the sorting question more generally.
Three ways to control order
| Approach | Strength | Weakness |
|---|---|---|
| Numeric filename prefixes | Works in any tool and in a plain file browser | Renumbering is tedious, and numbers can leak into titles |
| A navigation file | Order is explicit and reviewable in one place | Easy to forget when adding or renaming files |
| Alphabetical by title | Zero maintenance | Rarely matches a sensible reading order |
Numeric prefixes in practice
Prefixes such as 01_ are a common choice because they also order files in editors and on code hosting sites. A small helper can strip them for display.
def display_title(filename)
base = File.basename(filename, ".feature")
base.sub(/\A\d+[_-]/, "").tr("_-", " ").capitalize
end
files = Dir["features/**/*.feature"].sort
files.each { |f| puts display_title(f) }
Given 01_getting_started.feature, the helper prints Getting started, while the sort keeps the intended order.
Deciding on an order
- Start with orientation: what the thing is and how to install it.
- Follow with the most common tasks, in the order a newcomer meets them.
- Put configuration and advanced options after the basics.
- Finish with troubleshooting and edge cases.
Pitfalls
- Mixing approaches, such as prefixes in one folder and a nav file in another, confuses contributors.
- Sorting by file modification time gives a different order on every machine.
- Deeply nested folders defeat any ordering scheme. Two levels is usually enough.