Commit Graph

5 Commits

Author SHA1 Message Date
Krystine Sherwin e447713921
log_help: {add,push,pop}_content helpers 2025-01-15 09:25:38 +13:00
Krystine Sherwin 40d22adb36
log_help: Json dumpable
Current modes are `LOG` and `LISTING`, which `log()` and store for conversion to json respectively.
Add `ContentListing` listing struct to (recursively) contain help data for conversion to a json object to be exported and used elsewhere (e.g. the docs).
Rather than formatting as rst we can just export with type information and do the conversion at the destination (i.e. in the python code which loads the domain for autodoc).
Implement `PrettyHelp::has_content()`.
Provide `PrettyHelp::get_content()` which returns a read-only list of the current content.
`PrettyHelp` constructor takes optional `Mode` enum to define format of help content.
Updates `PrettyHelp` methods to use a switch case for checking current mode, calling `log_abort()` in the default case (i.e. unsupported mode).
2025-01-15 07:04:53 +13:00
Krystine Sherwin 36e5d4c3d5
log_help: Include source_location
Use `std::experimental::source_location` because clang support is `??`
Add `ENABLE_SOURCE_LOCATION` make variable and corresponding `YOSYS_ENABLE_SOURCE_LOCATION` define.
Dummy out the struct if disabled and check for null instead of using `#ifdef` blocks everywhere.
2025-01-14 16:27:51 +13:00
Krystine Sherwin 724d71e4a4
log_help: Options can have content
Refactor `PrettyHelp::endgroup()` -> `PrettyHelp::close(int levels = 1)`.
2025-01-14 15:56:22 +13:00
Krystine Sherwin 9cbb17061d
WIP docs: Proto log_help
Define `PrettyHelp` class with methods for declaring different parts of help message.
Currently able to produce standard help messages as expected.
Updates chformal to use (only) the new help_v2.
Currently makes use of a global static to track the current help context, allowing register.h to live in blissful ignorance and instead rely on help_v2 implementations calling `auto *help = PrettyHelp::get_current();` and `return true;` to minimise impact on rebuilds (i.e. not requiring every source file to be recompiled).
2025-01-14 14:10:10 +13:00