GithubHelp home page GithubHelp logo

adobe / hyde Goto Github PK

View Code? Open in Web Editor NEW
318.0 22.0 40.0 411 KB

A front-end to Jekyll that parses C++ sources to produce and enforce out-of-line documentation

Home Page: http://opensource.adobe.com/hyde/

License: MIT License

CMake 2.15% C++ 96.65% Shell 0.31% Dockerfile 0.88%
cplusplus documentation-tool jekyll libtooling

hyde's Introduction

What is hyde

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

  • Clang based: In order to properly document your C++, hyde compiles it using Clang's excellent libTooling library. Therefore, as the C++ language evolves, so too will hyde.
  • Out-of-line: Many tools rely on documentation placed inline within source as long-form comments. While these seem appealing at first blush, they suffer from two big drawbacks. First, there is nothing keeping the comments from falling out of sync from the elements they document. Secondly (and ironically), experienced users of these libraries eventually find inline documentation to be more of a distraction than a help, cluttering code with comments they no longer read.
  • Jekyll compatible: hyde does not produce pretty-printed output. Rather, it produces well structured Markdown files that contain YAML front-matter. These files can then be consumed by other tools (like Jekyll) to customize the structure and layout of the final documentation.
  • Schema enforcement: Because of the highly structured nature of the output, hyde is able to compare pre-existing documentation files against the current state of your C++ sources. Library developers can use hyde's update mode to facilitate updating documentation against the state of sources. Build engineers can use hyde's validate mode to make sure changes to a code base are accurately reflected in the latest documentation. In the end, the documentation stays true to the code with minimal effort.
  • Adaptable: While hyde's primary purpose at this point is to output and enforce documentation, the tool can also be used to output AST-based information about your code as a JSON-based IR. This makes room for additional tools to be build atop what hyde is able to produce, or additional emitters can be added natively to the tool.

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

  • Homebrew
    • brew install cmake
    • brew install ninja (optional)

Linux

(Note: only tested on ubuntu bionic so far)

  • Apt
    • sudo apt-get install libyaml-cpp-dev

How to Build

  • clone this repo
  • cd hyde
  • git submodule update --init
  • mkdir build
  • cd build
  • cmake .. -GNinja (or -GXcode, etc.)
  • ninja (or whatever your IDE does)

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.

Using Docker

You may need to increase your docker resources to build the image.

docker build --tag hyde .

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

Parameters and Flags

There are several modes under which the tool can run:

  • -hyde-json - (default) Output an analysis dump of the input file as JSON

  • -hyde-validate - Validate existing YAML documentation

  • -hyde-update - Write updated YAML documentation

  • -hyde-src-root = <path> - The root path to the header file(s) being analyzed. Affects defined_in_file output values by taking out the root path.

  • -hyde-yaml-dir = <path> - Root directory for YAML validation / update. Required for either hyde-validate or hyde-update modes.

  • --use-system-clang - Autodetect and use necessary resource directories and include paths

  • --fixup-hyde-subfield - As of Hyde v0.1.5, all hyde fields are under a top-level hyde subfield in YAML output. This flag will update older hyde documentation that does not have this subfield by creating it, then moving all top-level fields except title and layout under it. This flag is intended to be used only once during the migration of older documentation from the non-subfield structure to the subfield structure.

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

hyde's People

Contributors

abigagli avatar baheath avatar filmaj avatar fosterbrereton avatar jaredwy avatar kavanaanand avatar mmha avatar mowijo avatar nickpdemarco avatar sean-parent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyde's Issues

Command Line Options - relative paths inconsistent

Describe the bug
The path for -hyde-yaml-dir and -hyde-src-root is relative to the directory containing the file being processed. i.e.

hyde ./include/psutil/safe_cast.hpp -hyde-src-root=../../include -hyde-yaml-dir=../../docs/include

Here the path ../../include is relative to ./include/psutil/ and not the current working directory.

`--infer-owner` with `git blame`

Is your feature request related to a problem? Please describe.
This is a feature request.

Describe the solution you'd like
I would like an option added to hyde, --infer-owner (subject to bikeshedding) which instructs hyde to leverage git blame (or a comparable command for other version control systems) to make a best guess at the owner of a particular code segment (class, function, file, etc). This could be used to autofill the owner field of the emitted YAML and reduce the amount of manual work needed to update one's docs.

Describe alternatives you've considered
Additional context

Remove dependencie on Xcode

The tool does not run on platforms that do not have Xcode installed because there are some hardcoded paths in main.cpp. This prevents the tool from running on linux.
"Error: boost::filesystem::directory_iterator::construct: No such file or directory: "/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/"

Hyde update should reflect unknown tags in the YAML/JSON

The front matter in a Jekyll file may contain non-related tags to hyde. For example, the stlab libraries have a tag examples: that lists a set of example files to be referenced. Hyde update strips these tags. Another example is category: tags. It might be best if non-jekyl specific hyde tags themselves were name spaced so as not to conflict with other systems:

layout: function
title: at_pre_exit
owner: sean-parent
hyde:
    brief: Register the `pre_exit_handler` to be called on [`pre_exit()`](/libraries/pre_exit.hpp/f_pre_exit.html).
    tags:
      - function
    defined_in_file: pre_exit.hpp
    overloads:
      void at_pre_exit(stlab::pre_exit_handler):
        arguments:
          - description: __OPTIONAL__
            name: f
            type: stlab::pre_exit_handler
        description: Register the `pre_exit_handler` to be called on [`pre_exit()`](/libraries/pre_exit.hpp/f_pre_exit.html). The functions are called in the reverse order that they are registered.
        return: __OPTIONAL__
        signature_with_names: void at_pre_exit(stlab::pre_exit_handler f)
    namespace:
      - stlab
      - v1

Not finding path for standard library

Describe the bug
Executing a command like the following:

hyde ./include/psutil/safe_cast.hpp -hyde-src-root=../../include -hyde-yaml-dir=../../docs/include \
    -resource-dir=`clang++ --print-resource-dir` -access-filter-protected \
    -namespace-blacklist="safe_cast_detail" -hyde-update -- \
    -x c++ -std=c++14 -stdlib=libc++

Will error out trying to include any file in libc++. The workaround is to explicitly add the path:

 -I`xcode-select --print-path`/usr/include/c++/v1

Denote compiler-provided routines

We should include an annotation to routines that are compiler-supplied. (This is not the same as routines the user has defaulted.)

Incorrect Directory Titles

Describe the bug
The titles in the front matter for directory pages don't conform to the directories they're being generated from.

To Reproduce
Generate yaml for the following files:

  • a/b/h1.hpp
  • a/c/h2.hpp
  • a/d/h3.hpp

The title for the a directory page is a as expected, but the title for the a/b directory page is also a. I would expect the title to be b.

This does not appear to be a problem if correct documentation already exists. Only when generating it for the first time.

Expected behavior
The expectation is that the titles in the directory pages mirror the directories they are generated from.

Desktop (please complete the following information):

  • OS: MacOS Catalina
  • Clang 10.0.0

Additional context
After looking into this a little it seems that a recent fix was introduced to write titles when generating the directory stubs, and that that has caused this issue. The create_directory_stub defines a static stub_json_k variable which always contained just layout set to directory. A change was introduced to also write the title, but the title is not always the same so the variable should not have remained static.

Making stub_json_k no longer static improves the directory naming, but is not sufficient (as far as I can tell) because the title should not always be the path::filename() of the directory being created. If the directory name is mangled, then the mangled name is written to the title field. Then, later, during the call to reconcile the mangled name already exists and prevents the correct, demangled name from being written to the title field of the merged node.

I have worked around this locally by (a) making stub_json_k a local variable in the create_directory_stub function, and (b) only writing the title for "true" ancestors. So when creating path directories for a/b/c. I only set the title for a and b, but not for c. It seems to work, but I can't really tell whether it's really tackling the core of the problem.

Switch to more inclusive language

Could you please take some time in the next few days to make changes to some terminology in your repos and content as much as is possible:

  • Whitelist/blacklist to Allowed List and Blocked List (or Approve List/Deny List - some software uses this instead) respectively. Google and many developers are formalizing allowlist and blocklist. You might want to lobby for those terms to be used in the UI.
  • Master/Slave to master and replica (or subordinate, if that makes more sense) respectively.

If you cannot remove the term because the writing for example reflects the UI or the code, please make a note and send me an email to [email protected] so we can bring it that team’s attention. Thanks for your efforts in this matter.

Process a directory of files in parallel

Right now the tool can only handle one input file at a time. This should be fixed to take a directory of files that can be processed in parallel. The biggest hangup here will be the code that checks for extraneous / missing files, which is done on a per-header basis.

Empty enums generate error

Expected Behaviour

To be able to leave an empty enum in the code, e.g.:

enum Options {
    // add your amazing option here
}

Why would I do this? Perhaps I have a bunch of code dependent on the enum (but not specific enum values) that I'm not ready to delete, because I expect to introduce different values into the enum in the future.

Actual Behaviour

Empty enums generate an error:

ERROR:root:FAILED: Hyde-validate for <path>/<to>/options.hpp
ERROR:root:        stdout: 
ERROR:root:        stderr: <path>/<to>/<docs>/options.md: extraneous file
Error: YAML documentation failed to validate.

If options.md is removed, a different error is generated:

ERROR:root:FAILED: Hyde-validate for <path>/<to>/options.hpp
ERROR:root:        stdout: 
ERROR:root:        stderr: Error: YAML documentation failed to validate.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Create an empty enum and run hyde

Platform and Version

Mac OS.

Sample Code that illustrates the problem

enum Options {
    // add your amazing option here
}

Logs taken while reproducing problem

Better URL scheme/name demangling

Is it possible to demangle the names in the filenames? I feel a URL scheme is very important for documentation. A3CT12C20T23E is a lot less readable than A<T1,T2>.

'stddef.h' file not found

Running hyde on test_files/classes.cpp produces a fatal error:

./hyde -hyde-src-root=../test_files -hyde-yaml-dir=test_files_out -hyde-update ../test_files/classes.cpp --
In file included from .../hyde/test_files/classes.cpp:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:477:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:639:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/initializer_list:47:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstddef:44:15: fatal error: 'stddef.h' file not found
#include_next <stddef.h>
              ^~~~~~~~~~
1 error generated.
Error while processing .../hyde/test_files/classes.cpp.
Error: compilation failed.

I'm on macOS Mojave. Changing the hardcoded path in sources/main.cpp from .../clang/9.1.0/include to .../clang/10.0.0/include produces the same error, but about string.h:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found
#include_next <string.h>
              ^~~~~~~~~~
1 error generated.

use hyde as a clang-doc generator

Hi!

A friend of mine recommended this tool and I would like to use it on my libraries. I really like the output format, easy to read and easy to document. My only issue is integrating the tool itself into my build systems and pipelines.
My main idea was to use the compile_commands.json provided by cmake, but it seems this tool is not ready to accept multiple translation units.

Is your feature request related to a problem? Please describe.
This tool aims to provide documentation based on clang ast. There is already a similar tool in the llvm environment itself, called clang-doc. Would it be possible to merge the efforts of this project into that one?

Describe the solution you'd like
In my opinion the easiest solution would be to merge this repository into the clang-doc as a generator format. This would require minimal modification in the clang-doc itself, but would require acceptance.

Describe alternatives you've considered
Another option would be to extend clang-doc to accept external formatters, such as hyde. This would require modification in the clang-doc as right now it is not ready for that. Would also require modification in the hyde code base, but it would be very similar to the other approach. ( Fit to the Generator interface. )

Additional context
One option would be to support multiple translation units via Executor, but it would cause duplicate effort because clang-doc already does this.

Building fails on Ubuntu 20.04

Describe the bug

Building fails on ubuntu 20.04 with compiler errors.
A clear and concise description of what the bug is.

To Reproduce
Can easily be reproduced in a docker container:

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y \
    build-essential libboost-system-dev libboost-filesystem-dev libyaml-cpp-dev \
    libllvm9 llvm-9 llvm-9-dev clang-tools-9 libclang-common-9-dev clang-9 libclang-9-dev

# Install latest CMAKE. The one shipped by ubuntu 20.04 is too old.
RUN apt-get install -y software-properties-common lsb-release wget
# RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
COPY kitware.gpg /etc/apt/trusted.gpg.d/kitware.gpg
RUN apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
RUN apt-get update
RUN apt-get install -y kitware-archive-keyring
RUN rm /etc/apt/trusted.gpg.d/kitware.gpg
RUN apt-get update
RUN apt-get install -y cmake


# build hyde
COPY hyde-checkout /root/hyde
RUN mkdir /root/hyde/build
RUN ( cd /root/hyde/build && cmake .. && make -j )
RUN cp /root/hyde/build/hyde /usr/local/bin

BuildFROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y
build-essential libboost-system-dev libboost-filesystem-dev libyaml-cpp-dev
libllvm9 llvm-9 llvm-9-dev clang-tools-9 libclang-common-9-dev clang-9 libclang-9-dev

Install latest CMAKE. The one shipped by ubuntu 20.04 is too old.

RUN apt-get install -y software-properties-common lsb-release wget

RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null

COPY kitware.gpg /etc/apt/trusted.gpg.d/kitware.gpg
RUN apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
RUN apt-get update
RUN apt-get install -y kitware-archive-keyring
RUN rm /etc/apt/trusted.gpg.d/kitware.gpg
RUN apt-get update
RUN apt-get install -y cmake

build hyde

COPY hyde /root/hyde
RUN mkdir /root/hyde/build
RUN ( cd /root/hyde/build && cmake .. && make -j )
RUN cp /root/hyde/build/hyde /usr/local/bin```

Building the above docker image with

docker build . -t foo

will fail with the errors as seen in the build transcript at the bottom:

Expected behavior
I expect the build to pass.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Ubuntu Linux
  • Browser N/A
  • Version 20.04

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser N/A
  • Version N/A

Build Transcript

-- Build files have been written to: /root/hyde/build
[  2%] Building CXX object CMakeFiles/hyde.dir/emitters/yaml_base_emitter.cpp.o
[  4%] Building CXX object CMakeFiles/hyde.dir/emitters/yaml_class_emitter.cpp.o
[  6%] Building CXX object CMakeFiles/hyde.dir/emitters/yaml_enum_emitter.cpp.o
[  8%] Building CXX object CMakeFiles/hyde.dir/emitters/yaml_function_emitter.cpp.o
[ 10%] Building CXX object CMakeFiles/hyde.dir/emitters/yaml_library_emitter.cpp.o
[ 13%] Building CXX object CMakeFiles/hyde.dir/emitters/yaml_sourcefile_emitter.cpp.o
[ 17%] Building CXX object CMakeFiles/hyde.dir/matchers/class_matcher.cpp.o
[ 17%] Building CXX object CMakeFiles/hyde.dir/matchers/enum_matcher.cpp.o
[ 19%] Building CXX object CMakeFiles/hyde.dir/matchers/typealias_matcher.cpp.o
[ 21%] Building CXX object CMakeFiles/hyde.dir/matchers/function_matcher.cpp.o
[ 23%] Building CXX object CMakeFiles/hyde.dir/matchers/namespace_matcher.cpp.o
[ 26%] Building CXX object CMakeFiles/hyde.dir/matchers/typedef_matcher.cpp.o
[ 28%] Building CXX object CMakeFiles/hyde.dir/matchers/utilities.cpp.o
[ 30%] Building CXX object CMakeFiles/hyde.dir/sources/autodetect.cpp.o
[ 32%] Building CXX object CMakeFiles/hyde.dir/sources/main.cpp.o
[ 34%] Building CXX object CMakeFiles/hyde.dir/sources/output_yaml.cpp.o
[ 36%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/binary.cpp.o
[ 39%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/convert.cpp.o
[ 41%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/depthguard.cpp.o
[ 43%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/directives.cpp.o
[ 45%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/emit.cpp.o
[ 47%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/emitfromevents.cpp.o
[ 50%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/emitter.cpp.o
[ 52%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/emitterstate.cpp.o
[ 54%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/emitterutils.cpp.o
[ 56%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/exp.cpp.o
[ 58%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/exceptions.cpp.o
[ 60%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/memory.cpp.o
[ 63%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/node.cpp.o
[ 65%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/node_data.cpp.o
[ 67%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/nodebuilder.cpp.o
[ 69%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/nodeevents.cpp.o
[ 71%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/null.cpp.o
[ 73%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/ostream_wrapper.cpp.o
[ 76%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/parse.cpp.o
[ 78%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/parser.cpp.o
[ 80%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/regex_yaml.cpp.o
In file included from /usr/lib/llvm-9/include/clang/AST/RecursiveASTVisitor.h:23,
                 from /root/hyde/matchers/class_matcher.cpp:20:                                                                                                                                                                                                                
/usr/lib/llvm-9/include/clang/AST/DeclOpenMP.h:97:1: error: multi-line comment [-Werror=comment]                                                                                                                                                                               
   97 | /// #pragma omp declare reduction (foo : int,float : omp_out += omp_in) \                                                                                                                                                                                              
      | ^                                                                                                                                                                                                                                                                      
[ 82%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/scanner.cpp.o
[ 84%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/scanscalar.cpp.o
[ 86%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/scantag.cpp.o
[ 89%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/scantoken.cpp.o
[ 91%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/simplekey.cpp.o
[ 93%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/singledocparser.cpp.o
[ 95%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/stream.cpp.o
[ 97%] Building CXX object CMakeFiles/hyde.dir/submodules/yaml-cpp/src/tag.cpp.o
In file included from /root/hyde/matchers/namespace_matcher.cpp:25:
/root/hyde/matchers/utilities.hpp: In function 'std::string hyde::to_string(clang::AccessSpecifier)':
/root/hyde/matchers/utilities.hpp:73:1: error: control reaches end of non-void function [-Werror=return-type]
   73 | }
      | ^
In file included from /root/hyde/matchers/utilities.cpp:13:
/root/hyde/matchers/utilities.hpp: In function 'std::string hyde::to_string(clang::AccessSpecifier)':
/root/hyde/matchers/utilities.hpp:73:1: error: control reaches end of non-void function [-Werror=return-type]
   73 | }
      | ^
/root/hyde/matchers/utilities.cpp: In function 'bool hyde::AccessCheck(hyde::ToolAccessFilter, clang::AccessSpecifier)':
/root/hyde/matchers/utilities.cpp:557:1: error: control reaches end of non-void function [-Werror=return-type]
  557 | }
      | ^
In file included from /root/hyde/matchers/typealias_matcher.cpp:25:
/root/hyde/matchers/utilities.hpp: In function 'std::string hyde::to_string(clang::AccessSpecifier)':
/root/hyde/matchers/utilities.hpp:73:1: error: control reaches end of non-void function [-Werror=return-type]
   73 | }
      | ^
In file included from /root/hyde/matchers/typedef_matcher.cpp:25:
/root/hyde/matchers/utilities.hpp: In function 'std::string hyde::to_string(clang::AccessSpecifier)':
/root/hyde/matchers/utilities.hpp:73:1: error: control reaches end of non-void function [-Werror=return-type]
   73 | }
      | ^
In file included from /root/hyde/matchers/enum_matcher.cpp:25:
/root/hyde/matchers/utilities.hpp: In function 'std::string hyde::to_string(clang::AccessSpecifier)':
/root/hyde/matchers/utilities.hpp:73:1: error: control reaches end of non-void function [-Werror=return-type]
   73 | }
      | ^
/root/hyde/emitters/yaml_base_emitter.cpp: In function 'hyde::json {anonymous}::yaml_to_json(const YAML::Node&)':
/root/hyde/emitters/yaml_base_emitter.cpp:90:1: error: control reaches end of non-void function [-Werror=return-type]
   90 | }
      | ^
/root/hyde/emitters/yaml_base_emitter.cpp: In function 'YAML::Node {anonymous}::json_to_yaml(const json&)':
/root/hyde/emitters/yaml_base_emitter.cpp:135:1: error: control reaches end of non-void function [-Werror=return-type]
  135 | }
      | ^
At global scope:
cc1plus: error: unrecognized command line option '-Wno-range-loop-analysis' [-Werror]
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/hyde.dir/build.make:202: CMakeFiles/hyde.dir/matchers/namespace_matcher.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
At global scope:
cc1plus: error: unrecognized command line option '-Wno-range-loop-analysis' [-Werror]
cc1plus: all warnings being treated as errors
At global scope:
cc1plus: error: unrecognized command line option '-Wno-range-loop-analysis' [-Werror]
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/hyde.dir/build.make:244: CMakeFiles/hyde.dir/matchers/utilities.cpp.o] Error 1
make[2]: *** [CMakeFiles/hyde.dir/build.make:230: CMakeFiles/hyde.dir/matchers/typedef_matcher.cpp.o] Error 1
At global scope:
cc1plus: error: unrecognized command line option '-Wno-range-loop-analysis' [-Werror]
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/hyde.dir/build.make:174: CMakeFiles/hyde.dir/matchers/enum_matcher.cpp.o] Error 1
At global scope:
cc1plus: error: unrecognized command line option '-Wno-range-loop-analysis' [-Werror]
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/hyde.dir/build.make:216: CMakeFiles/hyde.dir/matchers/typealias_matcher.cpp.o] Error 1
In file included from /root/hyde/matchers/class_matcher.cpp:26:
/root/hyde/matchers/utilities.hpp: In function 'std::string hyde::to_string(clang::AccessSpecifier)':
/root/hyde/matchers/utilities.hpp:73:1: error: control reaches end of non-void function [-Werror=return-type]
   73 | }
      | ^
At global scope:
cc1plus: error: unrecognized command line option '-Wno-range-loop-analysis' [-Werror]
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/hyde.dir/build.make:76: CMakeFiles/hyde.dir/emitters/yaml_base_emitter.cpp.o] Error 1
At global scope:
cc1plus: error: unrecognized command line option '-Wno-range-loop-analysis' [-Werror]
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/hyde.dir/build.make:160: CMakeFiles/hyde.dir/matchers/class_matcher.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/hyde.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

-hyde-json project?

Hi,

We're trying to use hyde. We like the results so far! I want to ask about the -hyde-json workflow, instead of yaml. I'm aware that the stlab example uses structured Markdown files that contain YAML front-matter. I am wondering about the -hyde-json option though. Is there a complete example that uses json instead of yaml/markdown?

Thanks in advance!

Templates: no baseurl support

If you specify the site.baseurl then most of the templates fail, the solution is to replace usages of page.url with page.url | relative_url (note, if you set a baseurl in the _config.yml file then you can test and clean-up locally).

"title" should be scalar, not editable scalar

Describe the bug
When running Hyde, many classes etc get the name of their enclosing folder as the default "title" field, rather than the actual name of the thing.

Line 885 of yaml_base_emitter should be:
failure |= check_scalar(filepath, have, expected, "", merged, "title");

Rather than
failure |= check_editable_scalar(filepath, have, expected, "", merged, "title");

I don't believe title should be an "editable_scalar"

To Reproduce
Steps to reproduce the behavior:
Build and run Hyde on a fresh set of code. If the code has a file say foo.hpp with a class bar in it, the md file for the bar class will have foo.hpp as the title rather than bar.

Expected behavior
The title should be bar.

Screenshots
The above change seems to fix the problem

Desktop (please complete the following information):

  • OS: ubuntu, clang-9
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Alter project so builds fail faster

Right now the Clang dependencies are built before the hyde sources are. If there is an error in the hyde sources (especially building on Linux) the build takes more than two hours before those errors are discovered.

It would be great to build only the minimal number of Clang dependencies first to get the hyde sources built, then build the rest of Clang. That way if there are any failures in the hyde sources, they will be discovered sooner, saving us time.

Here are some initial attempts to alter CMakeLists.txt (the error message it produces will follow):

# Copyright 2018 Adobe
# All Rights Reserved.

# NOTICE: Adobe permits you to use, modify, and distribute this file in
# accordance with the terms of the Adobe license agreement accompanying
# it. If you have received this file from a source other than Adobe,
# then your use, modification, or distribution of it requires the prior
# written permission of Adobe.

cmake_minimum_required(VERSION 3.23)

set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) # Avoid overriding normal variables with option()
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW) # Avoid overriding normal variables with set(CACHE)

include(FetchContent)

set(FETCHCONTENT_QUIET FALSE)

set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")

project(hyde)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_XCODE_GENERATE_SCHEME OFF)

message(STATUS "INFO: Setting up LLVM...")

FetchContent_Declare(
    llvm
    GIT_REPOSITORY https://github.com/llvm/llvm-project.git
    GIT_TAG 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a # llvmorg-15.0.7
    GIT_SHALLOW TRUE
    GIT_PROGRESS TRUE
    SOURCE_SUBDIR llvm
)

set(LLVM_ENABLE_PROJECTS "clang")
set(LLVM_TARGETS_TO_BUILD "X86;AArch64")
set(LLVM_ENABLE_ZSTD OFF)

FetchContent_MakeAvailable(llvm)

message(STATUS "INFO: LLVM source dir: ${llvm_SOURCE_DIR}")
message(STATUS "INFO: LLVM binary dir: ${llvm_BINARY_DIR}")

set(SRC_SOURCES
    ${PROJECT_SOURCE_DIR}/sources/autodetect.cpp
    ${PROJECT_SOURCE_DIR}/sources/main.cpp
    ${PROJECT_SOURCE_DIR}/sources/output_yaml.cpp
)

set(SRC_EMITTERS
    ${PROJECT_SOURCE_DIR}/emitters/yaml_base_emitter.cpp
    ${PROJECT_SOURCE_DIR}/emitters/yaml_class_emitter.cpp
    ${PROJECT_SOURCE_DIR}/emitters/yaml_enum_emitter.cpp
    ${PROJECT_SOURCE_DIR}/emitters/yaml_function_emitter.cpp
    ${PROJECT_SOURCE_DIR}/emitters/yaml_library_emitter.cpp
    ${PROJECT_SOURCE_DIR}/emitters/yaml_sourcefile_emitter.cpp
)

set(SRC_MATCHERS
    ${PROJECT_SOURCE_DIR}/matchers/class_matcher.cpp
    ${PROJECT_SOURCE_DIR}/matchers/enum_matcher.cpp
    ${PROJECT_SOURCE_DIR}/matchers/function_matcher.cpp
    ${PROJECT_SOURCE_DIR}/matchers/namespace_matcher.cpp
    ${PROJECT_SOURCE_DIR}/matchers/typealias_matcher.cpp
    ${PROJECT_SOURCE_DIR}/matchers/typedef_matcher.cpp
    ${PROJECT_SOURCE_DIR}/matchers/utilities.cpp
)

set(SRC_YAMLCPP
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/binary.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/convert.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/depthguard.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/directives.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/emit.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/emitfromevents.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/emitter.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/emitterstate.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/emitterutils.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/exceptions.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/exp.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/memory.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/node.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/node_data.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/nodebuilder.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/nodeevents.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/null.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/ostream_wrapper.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/parse.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/parser.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/regex_yaml.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/scanner.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/scanscalar.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/scantag.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/scantoken.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/simplekey.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/singledocparser.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/stream.cpp
    ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/tag.cpp
)

# We make the hyde sources a library so that we can define these sources as a dependency of the
# executable. This will cause cmake to order the compilation of these files ahead of any other
# dependencies like Clang (because we specify this library as the first dependency of the
# executable.) The big benefit to this change is that they'll get compiled (and possibly
# break) _first_, letting builds fail faster than if Clang we're compiled ahead of these sources.

add_library(hyde_lib STATIC)

target_sources(hyde_lib
    PRIVATE
        ${SRC_SOURCES}
        ${SRC_EMITTERS}
        ${SRC_MATCHERS}
        ${SRC_YAMLCPP}
)

source_group(sources FILES ${SRC_SOURCES})
source_group(emitters FILES ${SRC_EMITTERS})
source_group(matchers FILES ${SRC_MATCHERS})
source_group(yaml-cpp FILES ${SRC_YAMLCPP})

target_include_directories(hyde_lib
    PUBLIC
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}/include
        ${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/include/
        ${PROJECT_SOURCE_DIR}/submodules/json/include/
        ${llvm_SOURCE_DIR}/clang/include
        ${llvm_BINARY_DIR}/tools/clang/include
        ${llvm_SOURCE_DIR}/llvm/include
        ${llvm_BINARY_DIR}/include
)

target_compile_options(hyde_lib
    PUBLIC
        -Wall
        -Wno-comment
        -Werror
        -Wno-range-loop-analysis
)

if (NOT LLVM_ENABLE_RTTI)
    target_compile_options(hyde_lib PRIVATE -fno-rtti)
endif()

# cmake won't let you make an executable with no source files, so we create a dummy empty file.
# See: https://stackoverflow.com/a/34234515/153535
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/null.cpp "// See CMakeLists.txt for the origin of this file.")
add_executable(hyde ${CMAKE_CURRENT_BINARY_DIR}/null.cpp)

target_link_libraries(hyde
    hyde_lib
    clang
    clangAST
    clangASTMatchers
    clangBasic
    clangFrontend
    clangLex
    clangTooling
)

if (PROJECT_IS_TOP_LEVEL)
    set_target_properties(hyde PROPERTIES XCODE_GENERATE_SCHEME ON)
endif()

Here is the error message produced by the build system:

[1/3639] Building CXX object CMakeFiles/hyde_lib.dir/sources/main.cpp.o
FAILED: CMakeFiles/hyde_lib.dir/sources/main.cpp.o 
/usr/bin/c++  -I/home/runner/work/hyde/hyde -I/home/runner/work/hyde/hyde/include -I/home/runner/work/hyde/hyde/submodules/yaml-cpp/include -I/home/runner/work/hyde/hyde/submodules/json/include -I/home/runner/work/hyde/hyde/build/_deps/llvm-src/clang/include -I/home/runner/work/hyde/hyde/build/_deps/llvm-build/tools/clang/include -I/home/runner/work/hyde/hyde/build/_deps/llvm-src/llvm/include -I/home/runner/work/hyde/hyde/build/_deps/llvm-build/include -O3 -DNDEBUG -std=c++20 -Wall -Wno-comment -Werror -Wno-range-loop-analysis -fno-rtti -MD -MT CMakeFiles/hyde_lib.dir/sources/main.cpp.o -MF CMakeFiles/hyde_lib.dir/sources/main.cpp.o.d -o CMakeFiles/hyde_lib.dir/sources/main.cpp.o -c /home/runner/work/hyde/hyde/sources/main.cpp
In file included from /home/runner/work/hyde/hyde/build/_deps/llvm-src/clang/include/clang/AST/ASTContext.h:18,
                 from /home/runner/work/hyde/hyde/build/_deps/llvm-src/clang/include/clang/Frontend/ASTUnit.h:17,
                 from /home/runner/work/hyde/hyde/build/_deps/llvm-src/clang/include/clang/Frontend/FrontendAction.h:23,
                 from /home/runner/work/hyde/hyde/build/_deps/llvm-src/clang/include/clang/Frontend/FrontendActions.h:12,
                 from /home/runner/work/hyde/hyde/sources/main.cpp:23:
/home/runner/work/hyde/hyde/build/_deps/llvm-src/clang/include/clang/AST/ASTFwd.h:21:10: fatal error: clang/AST/DeclNodes.inc: No such file or directory
   21 | #include "clang/AST/DeclNodes.inc"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[2/3[6](https://github.com/adobe/hyde/actions/runs/5613466345/job/15209547361#step:4:7)3[9](https://github.com/adobe/hyde/actions/runs/5613466345/job/15209547361#step:4:10)] Building CXX object CMakeFiles/hyde_lib.dir/sources/autodetect.cpp.o
[3/3639] Building CXX object CMakeFiles/hyde_lib.dir/sources/output_yaml.cpp.o
ninja: build stopped: subcommand failed.
Error: Process completed with exit code 1.

It would seem no reordering of dependencies in target_link_libraries causes the Clang dependencies to build before the hyde_lib dependencies. I suspect the clangAST and/or clangASTMatchers dependency is responsible for constructing clang/AST/DeclNodes.inc which the rest of the Clang headers depend on.

Allow specifying substitution characters

Currently the docs for a file like <lib/file.hpp> turns into a URL like lib2Ffile.hpp - it would be great to either allow lib-file.hpp or lib/file.hpp - similarly other special characters should be substituable to something more readable.

Example of HTML conversion

It would be great to have a standalone example of converting hyde's output into HTML. You have all the necessary bits in stlab, but it would be very convenient, speaking as a user, to have a stripped down example with just the essential parts (basically, Jenkins templates, if I understand it correctly).

(It would also be nice to have such an example for Hugo, but that's probably too much to ask.)

Be smarter about example files

Right now we permit example files to be included as siblings to the docs. (e.g., connect.md references connect_example.cpp.) These files are considered extraneous by the tool. We should permit all .cpp files in the output directories as long as they are start with the same name as a documentation file. Example:

m_connect.md // the doc file
m_connect_example.cpp // example file for connect. OK - do not flag.
m_foobar_example.cpp // example for a dead API, perhaps? Bad - should be flagged.

Make Complete How-to from Running Hyde, Writing Documentation to Serving in Jekyll

Dear Authors.

I am very interested in documenting my C++ code in a different approach than the normal "XML/Doxygen inline" mess and as such have found Hyde. Unfortunately, I have a hard time using Hyde in conjunction with Jekyll.

I have build and run Hyde just fine, installed and served Jekyll fine, but still I dont know how to actually serve the markdown generated by Hyde and how to write documentation on the methods.

I would suggest a full end to end example on how to document code.

If somebody can help me getting to actually serve documentation with Jekyll with method and class codumentation written by me, I will be happy to write such a tutorial.

Classes split over multiple files

I have the following situation (in many different situations):

// a.hpp
class A
{
    class B;

    void g(const B& b);
};

#include "b.hpp"
// b.hpp
class A::B
{
    void g();
};

If I run hyde on a.hpp alone, I don't get any output for B. If I run hyde with with b.hpp alone or passing both a.hpp and b.hpp, I get:

.../hyde/build/in/b.hpp:1:7: error: use of undeclared identifier 'A'
class A::B
      ^
1 error generated.

Is there a way to support this use case?

error: control reaches end of non-void function [-Werror=return-type]

A build error happens:

/home/sonzogna/programmation/download/hyde/emitters/yaml_base_emitter.cpp: In function ‘hyde::json {anonymous}::yaml_to_json(const YAML::Node&)’:
/home/sonzogna/programmation/download/hyde/emitters/yaml_base_emitter.cpp:90:1: error: control reaches end of non-void function [-Werror=return-type]

Compiler:

Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) 

cmake version 3.16.20200103-g19c2763

OS:

lsb_release -a
LSB Version:	core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04

Screenshots
asciicast

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.