Skip to content

Commit 2754f88

Browse files
authored
[mlir][docgen] Add option to enable Hugo Docs specific features (#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.
1 parent 4803ba9 commit 2754f88

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

mlir/cmake/modules/AddMLIR.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ endfunction()
188188
# Generate Documentation
189189
function(add_mlir_doc doc_filename output_file output_directory command)
190190
set(LLVM_TARGET_DEFINITIONS ${doc_filename}.td)
191-
tablegen(MLIR ${output_file}.md ${command} ${ARGN})
191+
# The MLIR docs use Hugo, so we allow Hugo specific features here.
192+
tablegen(MLIR ${output_file}.md ${command} -allow-hugo-specific-features ${ARGN})
192193
set(GEN_DOC_FILE ${MLIR_BINARY_DIR}/docs/${output_directory}${output_file}.md)
193194
add_custom_command(
194195
OUTPUT ${GEN_DOC_FILE}

mlir/tools/mlir-tblgen/OpDocGen.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ llvm::cl::opt<std::string>
4242
stripPrefix("strip-prefix",
4343
llvm::cl::desc("Strip prefix of the fully qualified names"),
4444
llvm::cl::init("::mlir::"), llvm::cl::cat(docCat));
45+
llvm::cl::opt<bool> allowHugoSpecificFeatures(
46+
"allow-hugo-specific-features",
47+
llvm::cl::desc("Allows using features specific to Hugo"),
48+
llvm::cl::init(false), llvm::cl::cat(docCat));
4549

4650
using namespace llvm;
4751
using namespace mlir;
@@ -213,7 +217,7 @@ static void emitOpDoc(const Operator &op, raw_ostream &os) {
213217
os << "<td><code>" << it.name << "</code></td><td>" << storageType
214218
<< "</td><td>";
215219
StringRef description = resolveAttrDescription(it.attr);
216-
if (!description.empty()) {
220+
if (allowHugoSpecificFeatures && !description.empty()) {
217221
// Expandable description.
218222
// This appears as just the summary, but when clicked shows the full
219223
// description.
@@ -227,7 +231,7 @@ static void emitOpDoc(const Operator &op, raw_ostream &os) {
227231
}
228232
os << "</td></tr>\n";
229233
}
230-
os << "<table>\n";
234+
os << "</table>\n";
231235
}
232236

233237
// Emit each of the operands.

0 commit comments

Comments
 (0)