diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -182,12 +182,23 @@ llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); std::error_code OK; - ExecutorName.setInitialValue("all-TUs"); - auto Exec = clang::tooling::createExecutorFromCommandLineArgs( - argc, argv, ClangDocCategory); + const char *Overview = + R"(Generates documentation from source code and comments. - if (!Exec) { - llvm::errs() << toString(Exec.takeError()) << "\n"; +Example usage for files without flags (default): + + $ clang-doc File1.cpp File2.cpp ... FileN.cpp + +Example usage for a project using a compile commands database: + + $ clang-doc --executor=all-TUs compile_commands.json +)"; + + auto Executor = clang::tooling::createExecutorFromCommandLineArgs( + argc, argv, ClangDocCategory, Overview); + + if (!Executor) { + llvm::errs() << toString(Executor.takeError()) << "\n"; return 1; } @@ -208,7 +219,7 @@ ArgAdjuster); clang::doc::ClangDocContext CDCtx = { - Exec->get()->getExecutionContext(), + Executor->get()->getExecutionContext(), ProjectName, PublicOnly, OutDirectory, @@ -239,7 +250,7 @@ // Mapping phase llvm::outs() << "Mapping decls...\n"; auto Err = - Exec->get()->execute(doc::newMapperActionFactory(CDCtx), ArgAdjuster); + Executor->get()->execute(doc::newMapperActionFactory(CDCtx), ArgAdjuster); if (Err) { if (IgnoreMappingFailures) llvm::errs() << "Error mapping decls in files. Clang-doc will ignore " @@ -256,7 +267,7 @@ // bitcode-encoded representation of the Info object. llvm::outs() << "Collecting infos...\n"; llvm::StringMap> USRToBitcode; - Exec->get()->getToolResults()->forEachResult( + Executor->get()->getToolResults()->forEachResult( [&](StringRef Key, StringRef Value) { auto R = USRToBitcode.try_emplace(Key, std::vector()); R.first->second.emplace_back(Value); diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -81,7 +81,7 @@ Improvements to clang-doc ------------------------- -The improvements are... +- The default executor was changed to standalone to match other tools. Improvements to clang-query --------------------------- diff --git a/clang-tools-extra/docs/clang-doc.rst b/clang-tools-extra/docs/clang-doc.rst --- a/clang-tools-extra/docs/clang-doc.rst +++ b/clang-tools-extra/docs/clang-doc.rst @@ -25,19 +25,23 @@ see `How To Setup Tooling For LLVM `_). -By default, the tool will run on all files listed in the given compile commands -database: +The tool will process a list of files by default: .. code-block:: console - $ clang-doc /path/to/compile_commands.json + $ clang-doc File1.cpp File2.cpp ... FileN.cpp -The tool can also be used on a single file or multiple files if a build path is -passed with the ``-p`` flag. +The tool can be also used with a compile commands database: .. code-block:: console - $ clang-doc /path/to/file.cpp -p /path/to/build + $ clang-doc --executor=all-TUs compile_commands.json + +To select only a subset of files from the database, use the ``--filter`` flag: + +.. code-block:: console + + $ clang-doc --executor=all-TUs --filter=File[0-9]+.cpp compile_commands.json Output ====== @@ -50,7 +54,7 @@ .. code-block:: console - $ clang-doc -output=output/directory/ compile_commands.json + $ clang-doc --output=output/directory/ compile_commands.json Configuration ============= @@ -67,6 +71,16 @@ .. code-block:: console $ clang-doc --help + OVERVIEW: Generates documentation from source code and comments. + + Example usage for files without flags (default): + + $ clang-doc File1.cpp File2.cpp ... FileN.cpp + + Example usage for a project using a compile commands database: + + $ clang-doc --executor=all-TUs compile_commands.json + USAGE: clang-doc [options] [... ] OPTIONS: