This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Enable generation of type constraint docs
AbandonedPublic

Authored by marbre on Jul 22 2021, 5:31 AM.

Details

Summary

This enables generating the documentation of type constraints. So far
this documentation is only generated as part of the full docs, generated
via --gen-dialect-doc.

Diff Detail

Event Timeline

marbre created this revision.Jul 22 2021, 5:31 AM
marbre requested review of this revision.Jul 22 2021, 5:31 AM

OOC when would one want to just have the type constraints? I was thinking most were moving towards full doc generation

OOC when would one want to just have the type constraints? I was thinking most were moving towards full doc generation

Well I plan to extend the EmitC dialect documentation. In order to do so, I need to replace

add_mlir_doc(EmitC EmitC Dialects/ -gen-dialect-doc)

I think the Buildin dialect is a good reference here:

add_mlir_doc(BuiltinAttributes BuiltinAttributes Dialects/ -gen-attrdef-doc)
add_mlir_doc(BuiltinLocationAttributes BuiltinLocationAttributes Dialects/ -gen-attrdef-doc)
add_mlir_doc(BuiltinOps BuiltinOps Dialects/ -gen-op-doc)
add_mlir_doc(BuiltinTypes BuiltinTypes Dialects/ -gen-typedef-doc)
add_mlir_doc(BuiltinTypes BuiltinTypeInterfaces Dialects/ -gen-type-interface-docs)

This allows to place the TOC at the correct position, to have a header like # 'emitc' Dialect only once, etc. This is hard to achieve when relying on -gen-dialect-doc, e.g. you cannot have the TOC at the top of the documentation or you have multiple TOCs. However, with not using -gen-dialect-doc, you loose the ability to document the type constraints.

OOC when would one want to just have the type constraints? I was thinking most were moving towards full doc generation

Well I plan to extend the EmitC dialect documentation. In order to do so, I need to replace

add_mlir_doc(EmitC EmitC Dialects/ -gen-dialect-doc)

I think the Buildin dialect is a good reference here:

add_mlir_doc(BuiltinAttributes BuiltinAttributes Dialects/ -gen-attrdef-doc)
add_mlir_doc(BuiltinLocationAttributes BuiltinLocationAttributes Dialects/ -gen-attrdef-doc)
add_mlir_doc(BuiltinOps BuiltinOps Dialects/ -gen-op-doc)
add_mlir_doc(BuiltinTypes BuiltinTypes Dialects/ -gen-typedef-doc)
add_mlir_doc(BuiltinTypes BuiltinTypeInterfaces Dialects/ -gen-type-interface-docs)

This allows to place the TOC at the correct position, to have a header like # 'emitc' Dialect only once, etc. This is hard to achieve when relying on -gen-dialect-doc, e.g. you cannot have the TOC at the top of the documentation or you have multiple TOCs. However, with not using -gen-dialect-doc, you loose the ability to document the type constraints.

Have you looked into fixing the issues with gen-dialect-doc? Or is it not easily feasible?

Have you looked into fixing the issues with gen-dialect-doc? Or is it not easily feasible?

I don't know if there is anything to fix in gen-dialect-doc. From my point of view it's fine that every generated file starts with

 # '${dialect} Dialect'

[TOC]

Otherwise you cannot fully rely on a pure auto-generated documentation. Removing those two auto-generated lines would force to add a custom markdown file to every dialect, which seems unnecessary. So I am not sure how we could "fix" gen-dialect-doc, but I am open for suggestions.
Anyway, if you want to put something in between of those two lines, you could do this generating several docs + adding a custom markdown file as the Builtin dialect does and that's fine. However, so far no possibility to generate docs on type constraints.

marbre abandoned this revision.Mar 23 2022, 4:52 AM