[Mlir-commits] [mlir] [mlir][docgen] Add option to enable Hugo Docs specific features (PR #68725)
Benjamin Maxwell
llvmlistbot at llvm.org
Tue Oct 10 09:56:47 PDT 2023
https://github.com/MacDue created https://github.com/llvm/llvm-project/pull/68725
This is set to off by default but enabled for the MLIR project, which uses Hugo Docs. Downstream projects can choose if they want to set this option or not.
Also fix an incorrectly closed `<table>` tag.
>From dd8587e68ce65789ab383d09b9b4eed0e83bc285 Mon Sep 17 00:00:00 2001
From: Benjamin Maxwell <benjamin.maxwell at arm.com>
Date: Tue, 10 Oct 2023 16:48:40 +0000
Subject: [PATCH] [mlir][docgen] Add option to enable Hugo Docs specific
features
This is set to off by default but enabled for the MLIR project, which
uses Hugo Docs. Downstream projects can choose if they want to set this
option or not.
Also fix an incorrectly closed `<table>` tag.
---
mlir/cmake/modules/AddMLIR.cmake | 3 ++-
mlir/tools/mlir-tblgen/OpDocGen.cpp | 8 ++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index 4622d4d05fcbdeb..544abe43688820e 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -188,7 +188,8 @@ endfunction()
# Generate Documentation
function(add_mlir_doc doc_filename output_file output_directory command)
set(LLVM_TARGET_DEFINITIONS ${doc_filename}.td)
- tablegen(MLIR ${output_file}.md ${command} ${ARGN})
+ # The MLIR docs use Hugo, so we allow Hugo specific features here.
+ tablegen(MLIR ${output_file}.md ${command} -allow-hugo-specific-features ${ARGN})
set(GEN_DOC_FILE ${MLIR_BINARY_DIR}/docs/${output_directory}${output_file}.md)
add_custom_command(
OUTPUT ${GEN_DOC_FILE}
diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index 088d34597f315fc..855f02d828418dd 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -42,6 +42,10 @@ llvm::cl::opt<std::string>
stripPrefix("strip-prefix",
llvm::cl::desc("Strip prefix of the fully qualified names"),
llvm::cl::init("::mlir::"), llvm::cl::cat(docCat));
+llvm::cl::opt<bool> allowHugoSpecificFeatures(
+ "allow-hugo-specific-features",
+ llvm::cl::desc("Allows using features specific to Hugo"),
+ llvm::cl::init(false), llvm::cl::cat(docCat));
using namespace llvm;
using namespace mlir;
@@ -213,7 +217,7 @@ static void emitOpDoc(const Operator &op, raw_ostream &os) {
os << "<td><code>" << it.name << "</code></td><td>" << storageType
<< "</td><td>";
StringRef description = resolveAttrDescription(it.attr);
- if (!description.empty()) {
+ if (allowHugoSpecificFeatures && !description.empty()) {
// Expandable description.
// This appears as just the summary, but when clicked shows the full
// description.
@@ -227,7 +231,7 @@ static void emitOpDoc(const Operator &op, raw_ostream &os) {
}
os << "</td></tr>\n";
}
- os << "<table>\n";
+ os << "</table>\n";
}
// Emit each of the operands.
More information about the Mlir-commits
mailing list