diff options
author | Dylan Fleming <Dylan.Fleming@arm.com> | 2022-07-21 11:11:48 +0000 |
---|---|---|
committer | Dylan Fleming <Dylan.Fleming@arm.com> | 2022-07-21 11:33:19 +0000 |
commit | 396e944d82f3e212746cd241e4caba445523aff6 (patch) | |
tree | f3963b382116c03426412ecbb568de85fb099707 /flang | |
parent | 8bb4451a651ac00432d04e020d83f43c445aaebb (diff) | |
download | llvm-396e944d82f3e212746cd241e4caba445523aff6.zip llvm-396e944d82f3e212746cd241e4caba445523aff6.tar.gz llvm-396e944d82f3e212746cd241e4caba445523aff6.tar.bz2 |
[Flang] Generate documentation for compiler flags
This patch aims to create a webpage to document
Flang's command line options on https://flang.llvm.org/docs/
in a similar way to Clang's
https://clang.llvm.org/docs/ClangCommandLineReference.html
This is done by using clang_tablegen to generate an .rst
file from Options.td (which is current shared with Clang)
For this to work, ClangOptionDocEmitter.cpp was updated
to allow specific Flang flags to be included,
rather than bulk excluding clang flags.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D129864
Diffstat (limited to 'flang')
-rw-r--r-- | flang/docs/CMakeLists.txt | 11 | ||||
-rw-r--r-- | flang/docs/index.md | 1 | ||||
-rw-r--r-- | flang/include/flang/FlangOptionsDocs.td | 35 |
3 files changed, 47 insertions, 0 deletions
diff --git a/flang/docs/CMakeLists.txt b/flang/docs/CMakeLists.txt index 044697a..077c01d 100644 --- a/flang/docs/CMakeLists.txt +++ b/flang/docs/CMakeLists.txt @@ -91,6 +91,16 @@ if (LLVM_ENABLE_DOXYGEN) endif() endif() +function (gen_rst_file_from_td output_file td_option source docs_target) + if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${source}") + message(FATAL_ERROR "Cannot find source file: ${source} in ${CMAKE_CURRENT_SOURCE_DIR}") + endif() + get_filename_component(TABLEGEN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${source}" DIRECTORY) + list(APPEND LLVM_TABLEGEN_FLAGS "-I${TABLEGEN_INCLUDE_DIR}") + clang_tablegen(Source/${output_file} ${td_option} SOURCE ${source} TARGET "gen-${output_file}") + add_dependencies(${docs_target} "gen-${output_file}") +endfunction() + if (LLVM_ENABLE_SPHINX) include(AddSphinxTarget) if (SPHINX_FOUND) @@ -114,6 +124,7 @@ if (LLVM_ENABLE_SPHINX) COMMAND "${Python3_EXECUTABLE}" ARGS ${CMAKE_CURRENT_BINARY_DIR}/Source/FIR/CreateFIRLangRef.py) + gen_rst_file_from_td(FlangCommandLineReference.rst -gen-opt-docs ../include/flang/FlangOptionsDocs.td docs-flang-html) endif() if (${SPHINX_OUTPUT_MAN}) add_sphinx_target(man flang) diff --git a/flang/docs/index.md b/flang/docs/index.md index 3c3e2de..d6b0511 100644 --- a/flang/docs/index.md +++ b/flang/docs/index.md @@ -45,6 +45,7 @@ on how to get in touch with us and to learn more about the current status. DoConcurrent Extensions FIRLangRef + FlangCommandLineReference FlangDriver FortranIR FortranLLVMTestSuite diff --git a/flang/include/flang/FlangOptionsDocs.td b/flang/include/flang/FlangOptionsDocs.td new file mode 100644 index 0000000..3205442 --- /dev/null +++ b/flang/include/flang/FlangOptionsDocs.td @@ -0,0 +1,35 @@ +//==--- FlangOptionDocs.td - Option documentation -------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +def GlobalDocumentation { + code Intro =[{.. + ------------------------------------------------------------------- + NOTE: This file is automatically generated by running clang-tblgen + -gen-opt-docs. Do not edit this file by hand!! + ------------------------------------------------------------------- + +===================================== +Flang command line argument reference +===================================== +.. contents:: + :local: + +Introduction +============ + +}]; + + string Program = "flang"; + + list<string> ExcludedFlags = []; + list<string> IncludedFlags = ["FlangOption"]; + +} + + +include "../../../clang/include/clang/Driver/Options.td" |