Writing Cloth documentation

Choose a page by the question a reader wants to answer. When a change affects what a programmer can write or how someone uses the compiler, update the relevant guide in the same pull request. Group related chapters in subject directories and link them from the manual’s index. Keep project plans and progress notes outside the repository.

Choose a page

  • Write a Cloth program. A first-program walkthrough shows the source, how to run it, and the expected result. Explain language rules in the language reference, as in Calls and results.

  • Use the compiler. Describe each option’s spelling, arguments, defaults, and valid combinations in the compiler flags reference. Put commands, supported native features, and link dependencies for --emit-object in the object-file guide.

  • Maintain the compiler. Describe the facts a pass produces or consumes, the implementation that owns them, and the tests that exercise the contract in the compiler internals chapters. The compiler overview links to those chapters.

  • Contribute to Cloth. Put workflows such as testing and submitting changes with the contributor guides.

For a range step, a programmer needs to know when the assignment runs and which counter value the body sees next. A maintainer needs to know which LLVM block supplies that value on the back edge. See Explicit steps and Backend control flow.

Review the layout

Pick a reader’s question, such as how Cloth chooses an overload. Try to reach the answer by following links from the repository README or the welcome page.

If the answer is hard to find, add a link whose text names the topic. Keep the full explanation on one page so future changes have one place to update. When moving a page or renaming a heading, update links to its old path or section.

Check an example

Check the behavior in the implementation and choose a test that exercises the claim. A frontend check can show that the compiler accepts a program. For a claim about output, use a test that runs the program.

Link to the tested source so readers can run the same example. The println test checks that the program prints Hello, world! on its own line and exits successfully. See the example program and its driver test.

Run this case from the repository root. On Windows with MinGW, use mingw32-make in place of make.

make test-file CASE=Tests/Compiler/Driver/println.test
View chapter on GitHub