github.com/bazelbuild/bazel-gazelle@v0.36.1-0.20240520142334-61b277ba6fed/docs/BUILD.bazel (about)

     1  """Documentation generation with stardoc
     2  
     3  This is in a separate package from both the stardoc source files and the
     4  resulting documentation markdown files, to prevent users trying to load()
     5  the stardoc repository, which is not a dependency users should install.
     6  """
     7  
     8  load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
     9  load("@bazel_skylib//rules:write_file.bzl", "write_file")
    10  load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
    11  
    12  # gazelle:ignore
    13  _DOC_SRCS = {
    14      "//internal:repository_docs": "repository.md",
    15      "//internal:extend_docs": "extend.md",
    16  }
    17  
    18  [
    19      stardoc(
    20          name = out.replace(".md", "_docgen"),
    21          out = out,
    22          # Convention: foo.bzl has bzl_library named "foo"
    23          input = input + ".bzl",
    24          deps = [input],
    25      )
    26      for [
    27          input,
    28          out,
    29      ] in _DOC_SRCS.items()
    30  ]
    31  
    32  [
    33      diff_test(
    34          name = "check_" + out,
    35          failure_message = "Please run bazel run //docs:update",
    36          # source file (InputArtifact)
    37          file1 = "//:" + out,
    38          # result from stardoc rule above
    39          file2 = out,
    40      )
    41      for out in _DOC_SRCS.values()
    42  ]
    43  
    44  write_file(
    45      name = "gen_update",
    46      out = "update.sh",
    47      content = [
    48          "#!/usr/bin/env bash",
    49          "cd $BUILD_WORKSPACE_DIRECTORY",
    50      ] + [
    51          "cp -fv bazel-bin/docs/{0} {0}".format(v)
    52          for v in _DOC_SRCS.values()
    53      ],
    54  )
    55  
    56  sh_binary(
    57      name = "update",
    58      srcs = ["update.sh"],
    59      data = _DOC_SRCS.values(),
    60  )