Generating the documentation
Similar to the crystal spec
command we learned about in Chapter 14, Testing, there is also a crystal docs
command. The most common scenario for generating code is within the context of a shard. In this case, all you need to do to generate the documentation is run crystal docs
. This will process all the code within src/
and output the generated website within a docs/
directory in the root of the project. From here, you can open docs/index.html
in your browser to view what was generated. Future invocations of crystal docs
will overwrite the previous files.
We can also pass an explicit list of files to this command; for example, crystal docs one.cr two.cr three.cr
. This will generate documentation for code within, or required by, all these files. You can use this to include external code within the generated documentation. For example, say you have a project that depends on two other shards within the same namespace. You could pass the main entry point...