Skip to content

[mlir][docgen] Add option to enable Hugo Docs specific features #68725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mlir/cmake/modules/AddMLIR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 6 additions & 2 deletions mlir/tools/mlir-tblgen/OpDocGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down