From c80d7a55df50d1c4ceaecdd73b41b6d78e8c2919 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Wed, 28 Feb 2024 01:00:16 +0100 Subject: [PATCH 1/5] Add trivial module docstrings --- deps.bzl | 2 ++ private/extensions.bzl | 2 ++ private/globals.bzl | 2 ++ private/globals_repo.bzl | 2 ++ private/parse.bzl | 2 ++ private/repos.bzl | 2 ++ private/util.bzl | 2 ++ private/version_repo.bzl | 2 ++ 8 files changed, 16 insertions(+) diff --git a/deps.bzl b/deps.bzl index 3ed76e1..a163bb9 100644 --- a/deps.bzl +++ b/deps.bzl @@ -1,3 +1,5 @@ +"""Contains the macro bazel_features_deps to install WORKSPACE dependencies.""" + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//private:repos.bzl", "bazel_features_repos") diff --git a/private/extensions.bzl b/private/extensions.bzl index 7314d9f..de2a453 100644 --- a/private/extensions.bzl +++ b/private/extensions.bzl @@ -1,3 +1,5 @@ +"""Internal module extensions.""" + load("//private:repos.bzl", "bazel_features_repos") def _version_extension_impl(_): diff --git a/private/globals.bzl b/private/globals.bzl index 0d755f8..a29210a 100644 --- a/private/globals.bzl +++ b/private/globals.bzl @@ -1,3 +1,5 @@ +"""Internal constants.""" + # Access any of these globals via bazel_features.globals. # If the current version of Bazel doesn't have this global, it will be None. GLOBALS = { diff --git a/private/globals_repo.bzl b/private/globals_repo.bzl index fcadfb2..89c2a4d 100644 --- a/private/globals_repo.bzl +++ b/private/globals_repo.bzl @@ -1,3 +1,5 @@ +"""Contains the internal repository rule globals_repo.""" + load("//private:parse.bzl", "parse_version") def _globals_repo_impl(rctx): diff --git a/private/parse.bzl b/private/parse.bzl index ee1576b..bead1cf 100644 --- a/private/parse.bzl +++ b/private/parse.bzl @@ -1,3 +1,5 @@ +"""Internal functions to parse versions.""" + def _safe_int(s, v): if not s.isdigit(): fail("invalid Bazel version '{}': non-numeric segment '{}'".format(v, s)) diff --git a/private/repos.bzl b/private/repos.bzl index 525452d..b9f675c 100644 --- a/private/repos.bzl +++ b/private/repos.bzl @@ -1,3 +1,5 @@ +"""Contains the macro bazel_features_repos to install internal repositories.""" + load(":globals.bzl", "GLOBALS") load(":globals_repo.bzl", "globals_repo") load(":version_repo.bzl", "version_repo") diff --git a/private/util.bzl b/private/util.bzl index 0f98077..501edfc 100644 --- a/private/util.bzl +++ b/private/util.bzl @@ -1,3 +1,5 @@ +"""Internal-only utility functions.""" + load("@bazel_features_version//:version.bzl", "version") load(":parse.bzl", "parse_version") diff --git a/private/version_repo.bzl b/private/version_repo.bzl index 4cee444..a82b558 100644 --- a/private/version_repo.bzl +++ b/private/version_repo.bzl @@ -1,3 +1,5 @@ +"""Contains the internal repository rule version_repo.""" + def _version_repo_impl(rctx): rctx.file( "BUILD.bazel", From 182552d22a715eeea329cab60fc02e403f98caee Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Wed, 28 Feb 2024 01:00:29 +0100 Subject: [PATCH 2/5] Reformat README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 47d1cdf..0481066 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Bazel Features -============== +# Bazel Features Use this to determine the availability of a Bazel feature in your ruleset. It works under the hood by comparing the Bazel version against a known range in which the feature is available. Example usage: From 1e08182cc24832c8e1abe7e1ba14a5d9352cda16 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Wed, 28 Feb 2024 01:00:42 +0100 Subject: [PATCH 3/5] Reformat renovate.json --- renovate.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/renovate.json b/renovate.json index 39a2b6e..4bd832f 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,4 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base" - ] + "extends": ["config:base"] } From e7e01cde07e7d094ed12b8f8a372ecef043b2862 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Wed, 28 Feb 2024 01:00:57 +0100 Subject: [PATCH 4/5] Given parse_version a complete docstring --- private/parse.bzl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/private/parse.bzl b/private/parse.bzl index bead1cf..b8ace53 100644 --- a/private/parse.bzl +++ b/private/parse.bzl @@ -15,7 +15,14 @@ def _partition(s): return s, "" def parse_version(v): - """Parses the given Bazel version string into a comparable value.""" + """Parses the given Bazel version string into a comparable value. + + Args: + v (str): version string + + Returns: + a triple ([major, minor, patch], is_released, prerelease) + """ if not v: # An empty string is treated as a "dev version", which is greater than anything. v = "999999.999999.999999" From fba142afca39bd39e4a19f35e0ee2785d35c6cad Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Wed, 28 Feb 2024 01:01:09 +0100 Subject: [PATCH 5/5] Move docstring to the right place --- test/bcr_test/test.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bcr_test/test.bzl b/test/bcr_test/test.bzl index 131d520..2a47df1 100644 --- a/test/bcr_test/test.bzl +++ b/test/bcr_test/test.bzl @@ -1,8 +1,8 @@ +"""Tests for `bazel_features` module.""" + load("@bazel_features//:features.bzl", "bazel_features") load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") -"""Tests for `bazel_features` module.""" - def _is_bzlmod_enabled_test(ctx): env = unittest.begin(ctx)