Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify package doc and github README.md (#72)
MOTIVATION Prior to this set of changes, two sets of documentation had to be maintained: the GitHub README.md and the Go package documentation in doc.go. The README.md file is a superset of documentation that includes the following items: - Various badge icons (build, godoc, coverage) - Getting started guide with sample applications - Comparison to other CLI tools - Installation instructions - A copy of the package doc.go - License information Because a copy of doc.go was included in README.md, over time these two versions have diverged. Committers updating README.md would forget to submit the same patches to doc.go and vice versa. Further complicating the situation is that GitHub markdown is more featureful (multi-level headings, lists, etc ...) than the simple and straightforward Go doc standards. Consequently, the package documentation (doc.go) contained within README.md acquired additional markup, further cementing the need to maintain two slightly different versions of the package documentation. Due to the above issues, contributing to the project's documentation was not an easy task. If done properly, a contributor would have to update the README.md document and then update the doc.go package documentation stripping out the markdown. This assumes the contributor was editing a portion of the docs that had not diverged over time. In that case, additional work was required to synchronize the documents. CHANGES This commit includes several changes to improve the overall documentation of the mow.cli project. Below is a short summary of each: - To eliminate the need to maintain two sets of nearly identical docs, the README.md file is now autogenerated using the Go autoreadme package. This tool generates a README.md from a README.md.template file. The template file includes all of the original README.md content (described above), but also includes placeholders where the contents of doc.go are included when the file is generated. - A new 'doc' target was added to the Makefile, which generates README.md for inclusion into the repository for GitHub. No changes should ever be made directly to the README.md file anymore as they will be overwritten when 'make doc' is executed. All changes should either be performed in README.md.template or doc.go. - Extensive edits to the Go package documentation, doc.go, were made to improve readability. This included numerous grammatical changes, rephrasing of sentences, ensuring consistency of examples, and rearrangement of the sections, so the docs were more accessible to new users. Old Ordering New Ordering ============ ============ - Basics - Basics - Options - Options - Arguments - Arguments - Operators - Operators - Commands - Commands - Custom Types - Interceptors - Interceptors - Exiting - Spec - Spec Strings - Spec Grammar - Spec Grammar - Default Spec - Default Spec - Exiting - Custom Types - Extensive reformatting of doc.go to ensure compliance with the basic Go doc style recommendations. This required eliminating extraneous headings and lists (bulleted and enumerated). Documentation can still be well-written without these constructs. By adhering to the Go doc guidelines, when the package documentation is included by autoreadme in the README.md, it looks natural and fits in with the overall look and feel of the original README.md document. One of the biggest challenges was dealing with the lack of multi- level headings in Go do. With only a single level heading, its use must be frugal. The prior README.md, however, made liberal use of sub-headings especially in the original Spec section. I simplified that entire section by writing each of the subsections as a separate paragraph with a single example, which maintains a rhythm for the reader making it flow as well, or perhaps even better, than that original README.md. - An additional example application called "A Larger Multi-Command Example" was written to show an alternate way of specifying the command structure where all commands are defined together in a section, but their implementation is deferred to functions. As a newcomer evaluating various CLI tools, I initially dismissed mow.cli because I did not like the style of defining every command in a single function as portrayed in the examples contained within README.md.
- Loading branch information