Home / Relish Service Documentation

Sorting Feature Files in Generated Documentation

The documentation that used to be at this address is no longer published, and its source was never released under an open license, so it is not reproduced here. This page is an independent guide to the same topic, written for this archive. It is not the project's documentation and is not affiliated with its authors.

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

ApproachStrengthWeakness
Numeric filename prefixesWorks in any tool and in a plain file browserRenumbering is tedious, and numbers can leak into titles
A navigation fileOrder is explicit and reviewable in one placeEasy to forget when adding or renaming files
Alphabetical by titleZero maintenanceRarely 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

  1. Start with orientation: what the thing is and how to install it.
  2. Follow with the most common tasks, in the order a newcomer meets them.
  3. Put configuration and advanced options after the basics.
  4. Finish with troubleshooting and edge cases.

Pitfalls

More on Relish Service Documentation

Explore the archive