{"id":39918243,"url":"https://github.com/jacobshirley/rules_docs","last_synced_at":"2026-03-18T01:02:00.170Z","repository":{"id":328026939,"uuid":"1107063356","full_name":"jacobshirley/rules_docs","owner":"jacobshirley","description":"Bazel rules for generating documentation and sites using tools such as mkdocs.","archived":false,"fork":false,"pushed_at":"2026-03-13T13:57:52.000Z","size":431,"stargazers_count":4,"open_issues_count":18,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-14T02:05:30.359Z","etag":null,"topics":["bazel","docs","rulesets"],"latest_commit_sha":null,"homepage":"https://jacobshirley.github.io/rules_docs/","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacobshirley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-30T14:07:19.000Z","updated_at":"2026-01-13T17:07:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jacobshirley/rules_docs","commit_stats":null,"previous_names":["jacobshirley/rules_docgen","jacobshirley/rules_docs"],"tags_count":5,"template":false,"template_full_name":"bazel-contrib/rules-template","purl":"pkg:github/jacobshirley/rules_docs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Frules_docs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Frules_docs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Frules_docs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Frules_docs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobshirley","download_url":"https://codeload.github.com/jacobshirley/rules_docs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobshirley%2Frules_docs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30638873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-18T00:09:27.587Z","status":"ssl_error","status_checked_at":"2026-03-18T00:09:26.123Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","docs","rulesets"],"created_at":"2026-01-18T17:06:01.561Z","updated_at":"2026-03-18T01:01:58.069Z","avatar_url":"https://github.com/jacobshirley.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rules_docs\n\nBazel rules for managing documentation and static site generation.\n\n\u003e **Notice:** _This package is in alpha (\u003c 1.0) and the API may change without notice until it reaches a stable release._\n\n## Features\n\n-   **Bazel targets**: Manage your documentation as Bazel targets\n-   **MkDocs**: Manage MkDocs (and plugins) using `rules_python` and generate static sites\n-   **Git integration**: Add last updated timestamps from git history\n-   **Linting**: Tested with https://vale.sh/ for linting prose, using rules_lint\n\n## Installation\n\n### Using Bzlmod (MODULE.bazel)\n\nAdd the following to your `MODULE.bazel`:\n\n```python\nbazel_dep(name = \"rules_docs\", version = \"0.0.0\")  # Use latest version\n```\n\nOptionally, you can specify a requirements.txt file for MkDocs and its plugins. This is needed if you want to use MkDocs plugins.\n\n```python\nbazel_dep(name = \"rules_python\", version = \"1.7.0\")\n\n# Configure Python and pip dependencies\npip = use_extension(\"@rules_python//python/extensions:pip.bzl\", \"pip\")\npip.parse(\n    hub_name = \"pypi\",\n    python_version = \"3.11\",\n    requirements_lock = \"//:requirements.txt\",\n)\nuse_repo(pip, \"pypi\")\n\n# Configure docgen with mkdocs plugins\ndocgen = use_extension(\"@rules_docs//docgen:extensions.bzl\", \"docgen\")\ndocgen.mkdocs(\n    plugins = [\n        \"mkdocs-glightbox\",\n        \"mkdocs-material\",\n        \"mkdocs-table-reader-plugin\",\n    ],\n    pypi_hub = \"@pypi\",\n)\nuse_repo(docgen, \"mkdocs\")\n```\n\nSee [requirements.txt](requirements.txt) for an example requirements file.\n\nTo install linting support, see the rules_lint documentation for running Vale over the targets created by rules_docs:\nhttps://registry.bazel.build/docs/aspect_rules_lint#lint-vale-bzl\n\n### Using WORKSPACE\n\nWorkspace is not supported. Please use Bzlmod.\n\n## Setting up custom MkDocs or MkDocs plugins\n\n### 1. Follow installation instructions above\n\nMake sure to include `rules_python` and configure pip dependencies as shown above.\n\n### 2. Create requirements.txt\n\nCreate a `requirements.in` file with mkdocs and desired plugins:\n\n```\nmkdocs\nmkdocs-material\nmkdocs-glightbox\nmkdocs-table-reader-plugin\npymdown-extensions\n```\n\nThen add a `BUILD.bazel` target to compile the requirements:\n\n```python\nload(\"@rules_python//python:pip.bzl\", \"compile_pip_requirements\")\n\ncompile_pip_requirements(\n    name = \"requirements\",\n    src = \"requirements.in\",\n    requirements_txt = \"requirements.txt\",\n)\n```\n\nTo create/update the `requirements.txt`, run:\n\n```bash\nbazel build //:requirements.update\n```\n\n### 3. Create mkdocs template (mkdocs.tpl.yaml)\n\nCreate a `mkdocs.tpl.yaml` file with your mkdocs configuration:\n\n```yaml\nsite_name: My Documentation\nrepo_url: https://github.com/yourusername/yourrepo\ndocs_dir: docs\nsite_dir: site\ntheme:\n    name: material\n    palette:\n        - media: '(prefers-color-scheme)'\n          primary: custom\n          accent: custom\n          toggle:\n              icon: material/brightness-auto\n              name: Switch to light mode\n        - media: '(prefers-color-scheme: light)'\n          scheme: default\n          primary: custom\n          accent: custom\n          toggle:\n              icon: material/brightness-7\n              name: Switch to dark mode\n        - media: '(prefers-color-scheme: dark)'\n          scheme: slate\n          primary: custom\n          accent: custom\n          toggle:\n              icon: material/brightness-4\n              name: Switch to system preference\n    features:\n        - navigation.path\nplugins:\n    - search\n    - table-reader\n    - glightbox\nmarkdown_extensions:\n    - tables\n    - pymdownx.superfences:\n          custom_fences:\n              - name: mermaid\n                class: mermaid\n                format: '!!python/name:pymdownx.superfences.fence_code_format'\n    - pymdownx.snippets:\n          check_paths: true\n          base_path:\n              - '!relative'\n```\n\n### 4. Create BUILD.bazel with documentation rules\n\n```python\nload(\"@rules_docs//docgen:defs.bzl\", \"docs\", \"docs_index\", \"docs_link\")\nload(\"@mkdocs//:defs.bzl\", \"mkdocs_build\", \"mkdocs_config\", \"mkdocs_serve\")\n\n# Define external links\ndocs_link(\n    name = \"docs_link\",\n    title = \"External Link\",\n    url = \"https://example.com\",\n    visibility = [\"//visibility:public\"],\n)\n\n# Create additional documentation sections\ndocs(\n    name = \"other_docs\",\n    entrypoint = \"other-info.md\",\n    readme_content = \"This is some other documentation content.\",\n)\n\n# Create nested navigation\ndocs_index(\n    name = \"sub_nav\",\n    nav = {\n        \":docs_link\": \"External Link\",\n        \"other-info.md\": \"Other Info\",\n        \":other_docs\": \"Other Docs\",\n    },\n    title = \"Sub Navigation\",\n)\n\n# Main documentation configuration\ndocs(\n    name = \"docs\",\n    nav = {\n        \"README.md\": \"Home\",\n        \":docs_link\": \"External Link\",\n        \"other-info.md\": \"Other Info\",\n        \":other_docs\": \"Other Docs\",\n        \":sub_nav\": \"\",  # Will use the title as the link text\n    },\n    readme_header_links = {\n        \":docs_link\": \"\",\n    },\n)\n\n# Generate mkdocs configuration\nmkdocs_config(\n    name = \"mkdocs_config\",\n    docs = \":docs\",\n    mkdocs_base = \"mkdocs.tpl.yaml\",\n)\n\n# Build documentation site\nmkdocs_build(\n    name = \"mkdocs\",\n    config = \":mkdocs_config\",\n    docs = [\":docs\"],\n    site_dir = \"site\",\n    visibility = [\"//visibility:public\"],\n)\n\n# Serve documentation locally for development\n# Recommended: run with ibazel for auto-reload on changes\nmkdocs_serve(\n    name = \"mkdocs.serve\",\n    config = \":mkdocs_config\",\n    docs = [\":docs\"],\n    visibility = [\"//visibility:public\"],\n)\n```\n\n## Usage\n\n### Building Documentation\n\nBuild the static documentation site:\n\n```bash\nbazel build //:mkdocs\n```\n\nThe built site will be in `bazel-bin/site/`.\n\n### Serving Documentation Locally\n\nServe the documentation with live reload (recommended with ibazel):\n\n```bash\n# With ibazel for auto-reload\nibazel run //:mkdocs.serve\n\n# Without ibazel\nbazel run //:mkdocs.serve\n```\n\nThen open your browser to http://localhost:8000\n\n### Navigation Structure\n\nThe `nav` attribute in the `docs` rule creates the navigation structure:\n\n-   **Markdown files**: `\"path/to/file.md\": \"Display Name\"`\n-   **External links**: `\":link_target\": \"Display Name\"` (references a `docs_link` target)\n-   **Other docs**: `\":docs_target\": \"Display Name\"` (references another `docs` target)\n-   **Nested nav**: `\":index_target\": \"\"` (references a `docs_index` target; empty string uses the index's title)\n\n## Example Project\n\nSee the complete working example in [e2e/smoke/](e2e/smoke/README.md) directory, which demonstrates:\n\n-   Both Bzlmod (MODULE.bazel) and WORKSPACE setups\n-   Complete BUILD.bazel configuration\n-   Navigation with external links and nested sections\n-   MkDocs configuration with Material theme\n-   Development server setup\n\nAlso see language- or framework-specific examples in the examples/ folder.\n\nThe examples/typescript folder also demonstrates how Vale can be setup to lint markdown prose.\n\n## Advanced Features\n\n### Git Last Updated Timestamps\n\nAdd last updated timestamps from git history to your documentation:\n\n```python\nload(\"@rules_docs//docgen:defs.bzl\", \"markdown_add_last_updated\", \"git_last_updated_timestamps\")\n\ngit_last_updated_timestamps(\n    name = \"git_last_updated_timestamps\",\n    srcs = glob([\"**/*.md\"]),\n    out = \"last_updated.json\",\n)\n\nmarkdown_add_last_updated(\n    name = \"docs_with_last_updated\",\n    docs = \":docs\",\n    last_updated_json = \":git_last_updated_timestamps\",\n    out_dir = \"last_updated_docs\",\n)\n```\n\nSee [e2e/git_last_updated/](e2e/git_last_updated/) for a complete example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobshirley%2Frules_docs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobshirley%2Frules_docs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobshirley%2Frules_docs/lists"}