bazelbuild / stardoc

Stardoc: Starlark Documentation Generator
Apache License 2.0
107 stars 42 forks source link

Provider `init` callback needs to be documented #182

Closed tetromino closed 4 months ago

tetromino commented 1 year ago

If a provider has init specified, we want to document it.

In other words,

def _my_info_init(a, c = "hello"):
    """
    MyInfo constructor

    Args:
          a: Value of field a
          c: Value to frobnicate
    """
    return {"a": a, "b": frobnicate(c)}

MyInfo = provider(
    doc = """This is my provider""",
    fields = {
        "a": "Field a",
        "b": "Field b (frobnicated)",
    },
    init = _my_info_init,
)

should get documented as something like


MyInfo

This is my provider

MyInfo(a, c)

MyInfo constructor

CONSTRUCTOR PARAMETERS

Name Description Default Value
a Value of field a none
c Value to frobnicate "hello"

FIELDS

Name Description
a Field a
b Field b (frobnicated)

This is a prerequisite for switching to stardoc / starlark_doc_extract for generating Bazel's own documentation.