adobe / hyde

A front-end to Jekyll that parses C++ sources to produce and enforce out-of-line documentation
http://opensource.adobe.com/hyde/
MIT License
323 stars 41 forks source link
cplusplus documentation-tool jekyll libtooling

What is hyde

hyde is a utility that facilitates documenting C++. The tool is unique from existing documentation utilities in the following ways:

Example Output

hyde produces intermediate documentation files that the developer then fills in with additional details as necessary. The files are then fed through a static site generation tool (like Jekyll) to produce output like this.

Requirements

macOS

Linux

(Note: only tested on ubuntu bionic so far)

How to Build

LLVM/Clang are declared as a dependency in the project's CMakeLists.txt file, and will be downloaded and made available to the project automatically.

How to run from Docker

docker pull ghcr.io/adobe/hyde:latest

docker run --platform linux/x86_64 --mount type=bind,source="$(pwd)",target=/mnt/host \
    --tty --interactive \
    ghcr.io/adobe/hyde:latest bash

You can then run the examples as below, except don't prefix hyde with ./.

Building the Docker image

You may need to increase your docker resources to build the image. (2.0.1 successfully built with 16GB RAM and 4GB swap)

docker build --tag hyde .

docker run --platform linux/x86_64 --mount type=bind,source="$(pwd)",target=/mnt/host \
    --tty --interactive \
    hyde bash

Publishing the docker image (requires write access to the adobe GitHub organization)

Instructions for publishing a GitHub package can be found here. Instructions for associating the with the adobe/hyde repository can be found here.

VERSION=2.0.1
docker tag hyde ghcr.io/adobe/hyde:$VERSION
docker tag hyde ghcr.io/adobe/hyde:latest
docker push ghcr.io/adobe/hyde:$VERSION
docker push ghcr.io/adobe/hyde:latest

Parameters and Flags

There are several modes under which the tool can run:

This tool parses the passed header using Clang. To pass arguments to the compiler (e.g., include directories), append them after the -- token on the command line. For example:

hyde input_file.hpp -hyde-json -use-system-clang -- -x c++ -I/path/to/includes

Alternatively, if you have a compilation database and would like to pass that instead of command-line compiler arguments, you can pass that with -p.

While compiling the source file, the non-function macro ADOBE_TOOL_HYDE is defined to the value 1. This can be useful to explicitly omit code from the documentation.

Examples:

To output JSON: ./hyde -use-system-clang ../test_files/classes.cpp --

To validate pre-existing YAML: ./hyde -use-system-clang -hyde-yaml-dir=/path/to/output -hyde-validate ../test_files/classes.cpp

To output updated YAML: ./hyde -use-system-clang -hyde-yaml-dir=/path/to/output -hyde-update ../test_files/classes.cpp

Hyde 1 to Hyde 2 Format Conversion

As of the Hyde 2 work, all subfields in the YAML output (except the Jekyll-required layout and title fields) must go under a top-level hyde subfield. This allows for other tools to include additional (possibly same-named) fields under their own top-level subfields in the YAML.

Here is an example of updating from Hyde 1 to Hyde 2 formatted docs by scanning a directory for markdown-formatted files and passing them to hyde with the new -hyde-fixup-subfield mode:

find . -name '*.md' | xargs -I % -L 1 /path/to/hyde -hyde-fixup-subfield % --

Sass Updates

Sometimes it may be necessary to clean up or "lint" the sass files. You can do so with:

bundle exec sass-convert -i /path/to/file.scss