Skip to content

Commit bfe1ae3

Browse files
committed
refactor: rename format option to generate and move it to the config
1 parent 6f0fdf7 commit bfe1ae3

File tree

12 files changed

+53
-62
lines changed

12 files changed

+53
-62
lines changed

.github/workflows/ci.yml

+22-28
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
shell: bash
6868
run: |
6969
set -xe
70-
70+
7171
# Determine LLVM configuration type
7272
llvm_config_type="${{ matrix.build-type }}"
7373
if [ "${{ runner.os }}" == "Windows" ]; then
@@ -85,14 +85,14 @@ jobs:
8585
llvm_commit_id=29b20829
8686
llvm_archive_filename="$llvm_runner_os-$llvm_config_type-$llvm_commit_id.$llvm_archive_type"
8787
llvm_url="https://github.com/cppalliance/mrdocs/releases/download/llvm-package-release/$llvm_archive_filename"
88-
88+
8989
if ! curl --head --silent --fail "$llvm_url"; then
9090
llvm_url="https://mrdox.com/llvm+clang/$llvm_archive_filename"
9191
fi
9292
9393
# Download LLVM binaries
9494
curl -L -o "$llvm_archive_filename" "$llvm_url"
95-
95+
9696
# Install LLVM to runner.tool_cache/llvm+clang
9797
llvm_root="${{runner.tool_cache}}/llvm+clang"
9898
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
@@ -194,10 +194,10 @@ jobs:
194194
gcov_tool="gcov-${{ steps.setup-cpp.outputs.version-major }}"
195195
fi
196196
lcov -c -q -o "./build/coverage.info" -d "./build" --include "$(pwd)/*" --gcov-tool "$gcov_tool"
197-
197+
198198
# Upload to codecov
199199
bash <(curl -s https://codecov.io/bash) -f "./build/coverage.info"
200-
200+
201201
# Update summary
202202
echo "# Coverage" >> $GITHUB_STEP_SUMMARY
203203
echo "" >> $GITHUB_STEP_SUMMARY
@@ -263,7 +263,7 @@ jobs:
263263
chmod 600 /home/runner/.ssh/github_actions
264264
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
265265
ssh-add /home/runner/.ssh/github_actions
266-
266+
267267
# Copy files
268268
chmod 755 -R $(pwd)/docs/build/site
269269
scp -r $(pwd)/docs/build/site/* [email protected]:/var/www/mrdox.com/
@@ -351,31 +351,25 @@ jobs:
351351
352352
- name: Generate demos
353353
run: |
354-
echo "verbose: true" > $(pwd)/boost/libs/url/mrdocs-single.yml
355-
echo "source-root: ." >> $(pwd)/boost/libs/url/mrdocs-single.yml
356-
echo "multipage: false" >> $(pwd)/boost/libs/url/mrdocs-single.yml
357-
echo "inaccessible-members: never" >> $(pwd)/boost/libs/url/mrdocs-single.yml
358-
echo "filters:" >> $(pwd)/boost/libs/url/mrdocs-single.yml
359-
echo " symbols:" >> $(pwd)/boost/libs/url/mrdocs-single.yml
360-
echo " exclude:" >> $(pwd)/boost/libs/url/mrdocs-single.yml
361-
echo " - 'boost::urls::detail'" >> $(pwd)/boost/libs/url/mrdocs-single.yml
362-
echo " - 'boost::urls::*::detail'" >> $(pwd)/boost/libs/url/mrdocs-single.yml
363-
364-
echo "verbose: true" > $(pwd)/boost/libs/url/mrdocs-multi.yml
365-
echo "source-root: ." >> $(pwd)/boost/libs/url/mrdocs-multi.yml
366-
echo "multipage: true" >> $(pwd)/boost/libs/url/mrdocs-multi.yml
367-
echo "inaccessible-members: never" >> $(pwd)/boost/libs/url/mrdocs-multi.yml
368-
echo "filters:" >> $(pwd)/boost/libs/url/mrdocs-multi.yml
369-
echo " symbols:" >> $(pwd)/boost/libs/url/mrdocs-multi.yml
370-
echo " exclude:" >> $(pwd)/boost/libs/url/mrdocs-multi.yml
371-
echo " - 'boost::urls::detail'" >> $(pwd)/boost/libs/url/mrdocs-multi.yml
372-
echo " - 'boost::urls::*::detail'" >> $(pwd)/boost/libs/url/mrdocs-multi.yml
373-
354+
config_template=$(printf '%s\n' \
355+
"verbose: true" \
356+
"source-root: ." \
357+
"generate: %s" \
358+
"multipage: %s" \
359+
"inaccessible-members: never" \
360+
"filters:" \
361+
" symbols:" \
362+
" exclude:" \
363+
" - 'boost::urls::detail'" \
364+
" - 'boost::urls::*::detail'" \
365+
)
374366
set -x
375367
for variant in single multi; do
376368
for format in adoc html xml; do
369+
[[ $variant = multi ]] && multiline="true" || multiline="false"
370+
printf "$config_template\n" $format $multiline > $(pwd)/boost/libs/url/mrdocs.yml
377371
mkdir -p "demos/boost-url/$variant/$format"
378-
mrdocs --config="$(pwd)/boost/libs/url/mrdocs-$variant.yml" "$(pwd)/boost/libs/url/__build__/compile_commands.json" --addons="$(pwd)/share/mrdocs/addons" --format="$format" --output="$(pwd)/demos/boost-url/$variant/$format"
372+
mrdocs --config="$(pwd)/boost/libs/url/mrdocs.yml" "$(pwd)/boost/libs/url/__build__/compile_commands.json" --addons="$(pwd)/share/mrdocs/addons" --output="$(pwd)/demos/boost-url/$variant/$format"
379373
done
380374
asciidoctor -R "$(pwd)/demos/boost-url/$variant/adoc" -D "$(pwd)/demos/boost-url/$variant/adoc-asciidoc" "$(pwd)/demos/boost-url/$variant/adoc/**/*.adoc"
381375
done
@@ -401,7 +395,7 @@ jobs:
401395
chmod 600 /home/runner/.ssh/github_actions
402396
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
403397
ssh-add /home/runner/.ssh/github_actions
404-
398+
405399
# Copy files
406400
demo_dir="/var/www/mrdox.com/demos/${{ github.ref_name }}"
407401
ssh [email protected] "rm -rf $demo_dir; mkdir -p $demo_dir"

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ if (MRDOCS_BUILD_DOCS)
338338
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
339339
add_mrdocs(generate_reference
340340
CONFIG docs/mrdocs.yml
341-
FORMAT adoc
342341
COMMENT "Generate MrDocs reference"
343342
OUTPUT ${MRDOCS_REFERENCE_OUTPUT_DIR}
344343
${REFERENCE_SOURCES})

docs/modules/ROOT/pages/config-file.adoc

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[,yaml]
44
----
5+
generate: # <.>
56
concurrency: # <.>
67
defines: # <.>
78
ignore-failures: # <.>
@@ -15,6 +16,7 @@ anonymous-namespaces: # <.>
1516
inaccessible-members: # <.>
1617
inaccessible-bases: # <.>
1718
----
19+
<.> Optional `generate` key
1820
<.> Optional `concurrency` key
1921
<.> Optional `defines` key
2022
<.> Optional `ignore-failures` key
@@ -33,6 +35,11 @@ inaccessible-bases: # <.>
3335
|===
3436
|Keys |Description |Required
3537

38+
|concurrency
39+
|The generator to use. Supported generators are
40+
`adoc`, `html`, and `xml`. Defaults to `adoc`.
41+
|No
42+
3643
|concurrency
3744
|The amount of parallelism desired. 0 to use
3845
the hardware-suggested concurrency.

docs/modules/ROOT/pages/usage.adoc

+3-8
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ The following command will generate the documentation with the most common optio
3737
----
3838
cd $PROJECT_BUILD_DIR
3939
MRDOCS_OUTPUT=$PROJECT_BUILD_DIR/docs/reference/adoc
40-
$MRDOCS_ROOT/mrdocs $PROJECT_BUILD_DIR/compile_commands.json --format=adoc --config=$MRDOCS_CONFIG --addons=$MRDOCS_ROOT/addons --output=$MRDOCS_OUTPUT
40+
$MRDOCS_ROOT/mrdocs $PROJECT_BUILD_DIR/compile_commands.json --config=$MRDOCS_CONFIG --addons=$MRDOCS_ROOT/addons --output=$MRDOCS_OUTPUT
4141
----
4242

4343
Here's a description of these options:
4444

45-
* `--format=adoc`: the output format.
46-
It can be any of the generators available.
4745
* `--config=$MRDOCS_CONFIG`: the path to the `mrdocs.yml` configuration file.
48-
This file more advanced information about the project.
46+
This file configures which generator is used, which directory to process,
47+
and what symbols should be extracted.
4948
* `--addons=$MRDOCS_ROOT/addons`: the path to the `addons` directory.
5049
This directory contains the addons that are used to generate the documentation.
5150
Among other things, it contains the default templates for the generator.
@@ -96,7 +95,6 @@ set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTOR
9695
add_mrdocs(<name>
9796
[EXCLUDE_FROM_ALL]
9897
[CONFIG <mrdocs.yml>]
99-
[FORMAT <format>]
10098
[ADDONS <addons-dir>]
10199
[COMMENT comment]
102100
[OUTPUT <output-dir>]
@@ -112,9 +110,6 @@ See documentation of the https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FR
112110
* The `CONFIG` option specifies the path to the `mrdocs.yml` configuration file.
113111
If not specified, the function will look for the configuration file in your project directory.
114112

115-
* The `FORMAT` option specifies the generator used by MrDocs.
116-
If this option is not specified, the function will use the default generator, which is `adoc`.
117-
118113
* The `ADDONS` option specifies a custom path to the `addons` directory. By default, the function will use the `addons` directory in the MrDocs installation directory.
119114

120115
* The `OUTPUT` option specifies the path to the output directory.

docs/mrdocs.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
verbose: true
22
source-root: ../include
3-
multipage: false
3+
multipage: false
4+
generate: adoc

include/mrdocs/Config.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ class MRDOCS_DECL
4545

4646
struct Settings
4747
{
48+
/** Selected documentation generator.
49+
50+
The currently supported generators are:
51+
52+
@li `adoc`: Generates documentation in the AsciiDoc format.
53+
@li `html`: Generates documentation as plain HTML.
54+
@li `xml`: Generates an XML representation of the corpus.
55+
*/
56+
std::string generate = "adoc";
57+
4858
/** `true` if output should consist of multiple files.
4959
*/
5060
bool multiPage = false;

share/cmake/MrDocs.cmake

+3-10
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function(add_mrdocs MRDOCS_TARGET_NAME)
2929
#-------------------------------------------------
3030
set(options_prefix MRDOCS_TARGET)
3131
set(options EXCLUDE_FROM_ALL)
32-
set(oneValueArgs CONFIG OUTPUT FORMAT ADDONS)
32+
set(oneValueArgs CONFIG OUTPUT ADDONS)
3333
set(multiValueArgs COMMENT)
3434
cmake_parse_arguments(${options_prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
3535
set(MRDOCS_TARGET_SOURCES ${MRDOCS_TARGET_UNPARSED_ARGUMENTS})
@@ -95,13 +95,6 @@ function(add_mrdocs MRDOCS_TARGET_NAME)
9595
endif()
9696
get_filename_component(MRDOCS_TARGET_CONFIG ${MRDOCS_TARGET_CONFIG} ABSOLUTE)
9797

98-
#-------------------------------------------------
99-
# Format
100-
#-------------------------------------------------
101-
if (NOT MRDOCS_TARGET_FORMAT)
102-
set(MRDOCS_TARGET_FORMAT adoc)
103-
endif()
104-
10598
#-------------------------------------------------
10699
# Format
107100
#-------------------------------------------------
@@ -150,7 +143,7 @@ function(add_mrdocs MRDOCS_TARGET_NAME)
150143
# Output
151144
#-------------------------------------------------
152145
if (NOT MRDOCS_TARGET_OUTPUT)
153-
set(MRDOCS_TARGET_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mrdocs/${MRDOCS_TARGET_FORMAT})
146+
set(MRDOCS_TARGET_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mrdocs)
154147
endif()
155148

156149

@@ -159,7 +152,7 @@ function(add_mrdocs MRDOCS_TARGET_NAME)
159152
#-------------------------------------------------
160153
message(STATUS "MrDocs: Generating documentation for ${CMAKE_PROJECT_NAME} in ${MRDOCS_TARGET_OUTPUT}")
161154
set(MRDOCS_CMD_LINE_OPTIONS --config=${MRDOCS_TARGET_CONFIG} ${MRDOCS_COMPILE_COMMANDS}
162-
--addons=${MRDOCS_TARGET_ADDONS} --format=${MRDOCS_TARGET_FORMAT} --output=${MRDOCS_TARGET_OUTPUT})
155+
--addons=${MRDOCS_TARGET_ADDONS} --output=${MRDOCS_TARGET_OUTPUT})
163156
string(REPLACE ";" " " MRDOCS_WS_CMD_LINE_OPTIONS "${MRDOCS_CMD_LINE_OPTIONS}")
164157
message(STATUS "mrdocs ${MRDOCS_WS_CMD_LINE_OPTIONS}")
165158
add_custom_target(

src/lib/Lib/ConfigImpl.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
// Copyright (c) 2023 Vinnie Falco ([email protected])
8+
// Copyright (c) 2023 Krystian Stasiowski ([email protected])
89
//
910
// Official repository: https://github.com/cppalliance/mrdocs
1011
//
@@ -96,6 +97,7 @@ struct llvm::yaml::MappingTraits<SettingsImpl>
9697
io.mapOptional("inaccessible-bases", cfg.inaccessibleBases);
9798

9899

100+
io.mapOptional("generate", cfg.generate);
99101
io.mapOptional("multipage", cfg.multiPage);
100102
io.mapOptional("source-root", cfg.sourceRoot);
101103

src/lib/Lib/ConfigImpl.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ class ConfigImpl
9696
*/
9797
std::vector<std::string> defines;
9898

99-
/** The list of formats to generate
100-
*/
101-
std::vector<std::string> generate;
102-
10399
/** `true` if AST visitation failures should not stop the program.
104100
105101
@code

src/tool/GenerateAction.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ DoGenerateAction()
5050
threadPool);
5151
if(! configFile)
5252
return configFile.error();
53+
5354
config = std::move(configFile.value());
5455
}
5556

5657

5758
// Create the generator
58-
auto generator = generators.find(toolArgs.formatType.getValue());
59+
auto generator = generators.find(config->settings().generate);
5960
if(! generator)
6061
return formatError("the Generator \"{}\" was not found",
61-
toolArgs.formatType.getValue());
62+
config->settings().generate);
6263

6364
// Load the compilation database
6465
if(toolArgs.inputPaths.empty())

src/tool/ToolArgs.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ R"(
3838
3939
EXAMPLES:
4040
mrdocs .. ( compile-commands )
41-
mrdocs --format adoc compile_commands.json
41+
mrdocs compile_commands.json
4242
)")
4343

4444
//
@@ -75,11 +75,6 @@ R"(
7575
llvm::cl::desc("Directory or file for generating output."),
7676
llvm::cl::init("."))
7777

78-
, formatType(
79-
"format",
80-
llvm::cl::desc("Format for the emitted documentation (\"adoc\", \"xml\", or \"html\")."),
81-
llvm::cl::init("adoc"))
82-
8378
, ignoreMappingFailures(
8479
"ignore-map-errors",
8580
llvm::cl::desc("Continue if files are not mapped correctly."),
@@ -105,7 +100,6 @@ hideForeignOptions()
105100
&configPath,
106101
&outputPath,
107102
std::addressof(inputPaths),
108-
&formatType,
109103
&ignoreMappingFailures,
110104
});
111105

src/tool/ToolArgs.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class ToolArgs
3737

3838
llvm::cl::opt<std::string> configPath;
3939
llvm::cl::opt<std::string> outputPath;
40-
llvm::cl::opt<std::string> formatType;
4140
llvm::cl::opt<bool> ignoreMappingFailures;
4241
llvm::cl::list<std::string> inputPaths;
4342

0 commit comments

Comments
 (0)