Skip to content

API: convention for short and long descriptions #6516

Closed

Description

@helderco

Because of core chaining in dagger call <command> --help:

The inconsistency in documenting the API is really noticeable. Since we want to list a short description next to commands and flags in the CLI, I suggest we apply a convention of writing the most concise short description in the first line, a blank line, and a more elaborate description.

Prior art

Many languages use this simple convention for docstrings (for example, Python), though some styles may differ. For example, in Python, the first line should end in a period, while there are others that don’t.

Git commit messages also follow this convention to separate the subject from the body with a new line. It’s meant to be easier to read with git log, for example. We have a similar need for the descriptions from the API to be easier to read in the CLI. Both function descriptions and arguments are presented next to their name, so short is better to avoid the need for wrapping.

I’m inspired by git “rules” for the commit messages:

  1. It should be capitalized.
  2. It shouldn’t end with a period
  3. It should be 50 characters or less

GitHub actually warns you if you go over this limit, and truncates any commit message longer than 72 characters.

Here’s a model git commit message (from Tim Pope):

Capitalized, short (50 chars or less) summary

More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.

For the CLI and other contexts, the first line can be split from the rest to provide a short summary. Looking at a few CLIs that use Cobra, they usually don’t include a final period in the Short description. It makes sense to save that extra char on listings, and it can be added by an SDK’s codegen to follow language conventions like Python.

Enforcing

Since the schema is now built from code, there's a nice touch from @vito in dagQL where Doc and ArgDoc accept a variadic where arguments are joined by two new lines (\n\n). We can additionally check if the first line is too long (> 50 chars) for example, and raising a warning if it doesn’t follow a convention.

\cc @sipsma

Activity

  1. added
    area/engine
    on Jan 29, 2024
  2. removed
    area/engine
    on May 31, 2024
  3. added
    kind/consistency
    on Jul 31, 2024
  4. locked and limited conversation to collaborators on Mar 24, 2026
  5. converted this issue into a discussion #12452 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/engine/apikind/consistency

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions