Repository navigation
Description
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:
- It should be capitalized.
- It shouldn’t end with a period
- 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