Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stardoc for bzlmod #776

Merged
merged 4 commits into from
Oct 18, 2023
Merged

Conversation

luispadron
Copy link
Collaborator

@luispadron luispadron commented Oct 16, 2023

This PR updates stardoc for use with bzlmod. This is required as the versions of stardoc on the registry require these stricter deps changes.

This updates our documentation (i.e. stardoc and bzl_library targets) to work in a similar way to rules_apple: https://github.com/bazelbuild/rules_apple/blob/master/apple/BUILD#L33

Each file we want documentation generated for defines it's own bzl_library with it's own set of deps. These target names are then used within the stardoc rule to generate documentation for each of them.

The main change is going from one giant bzl_library to multiple bzl_library.

Depends on the following stack:

@luispadron
Copy link
Collaborator Author

I plan to PR two things before this PR is merged but that it depends on:

  • Updating Bazel verison, we need >= 6.3.2 to fix issues with bzlmod and stardoc
  • Update to use bazel_skylib's write_file rule vs our custom copy of it, reduces code duplication and amount of bzl_library needed to create

@luispadron luispadron force-pushed the luis/update-stardoc-for-bzlmod branch from 3075874 to c5eb90b Compare October 16, 2023 22:57
@luispadron luispadron force-pushed the luis/update-stardoc-for-bzlmod branch 2 times, most recently from 55a090a to 8c87c5d Compare October 16, 2023 23:05
@luispadron luispadron changed the base branch from master to luis/use-bazel-skylib-write_file October 16, 2023 23:14
@luispadron luispadron force-pushed the luis/update-stardoc-for-bzlmod branch from 8c87c5d to 52c657a Compare October 16, 2023 23:15
@luispadron luispadron marked this pull request as ready for review October 16, 2023 23:15
load("@build_bazel_rules_apple//apple:apple.bzl", "apple_dynamic_framework_import", "apple_static_framework_import")
load("@build_bazel_rules_apple//apple/internal:apple_framework_import.bzl", "apple_dynamic_framework_import", "apple_static_framework_import")
Copy link
Collaborator Author

@luispadron luispadron Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing from apple.bzl umbrella import to specific internal import works around an issue i reported in stardoc + bzlmod: bazelbuild/stardoc#192

Comment on lines +171 to +181
_maybe(
http_archive,
name = "io_bazel_stardoc",
sha256 = "62bd2e60216b7a6fec3ac79341aa201e0956477e7c8f6ccc286f279ad1d96432",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz",
"https://github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz",
],
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this from WORKSPACE to the dev_dependencies section so that it matches the other rules_ios deps.

Comment on lines +56 to +70
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps")

stardoc_external_deps()

load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install")

stardoc_pinned_maven_install()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required by new stardoc versions

Comment on lines 6 to -27
workspace(name = "build_bazel_rules_ios")

# TODO: stardoc doesn't currently support bzlmod: https://github.com/bazelbuild/stardoc/issues/117
# Once that closes we should depend on it via the WORKSPACE file.
# In the meantime, this is a workaround to at least allow building.
# Note however that updating docs with bzlmod will not work until the above is resolved.
# Until then use: --noenable_bzlmod
load(
"@bazel_tools//tools/build_defs/repo:git.bzl",
"git_repository",
)

git_repository(
name = "io_bazel_stardoc",
commit = "6f274e903009158504a9d9130d7f7d5f3e9421ed",
remote = "https://github.com/bazelbuild/stardoc.git",
shallow_since = "1667581897 -0400",
)

load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now fully bzlmod 🎉

@luispadron luispadron force-pushed the luis/update-stardoc-for-bzlmod branch from 52c657a to f18dc96 Compare October 17, 2023 00:18
@luispadron luispadron force-pushed the luis/update-stardoc-for-bzlmod branch from f18dc96 to 890aa9a Compare October 17, 2023 00:24
Copy link
Collaborator

@justinseanmartin justinseanmartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take comments with a grain of salt and nothing that I'd consider a blocker to landing this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file name here and xcconfig.doc_doc.md seem odd

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixed this, should be generated correctly now

@@ -0,0 +1,10 @@
load(
"//rules/library:xcconfig.bzl",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this live under rules/library/xcconfig.doc.bzl to be next to its associated rule? I presume we don't want all of //rules/library:xcconfig.bzl to be considered public API, so we're cherry-picking a subset of it here? Should we mark the rest as internal symbols with an underscore prefix or something, if that prevents it from being documented?

Same feedback for vfs_overlay.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of .doc.bzl matches what rules_apple does, it's exporting the public api of xcconfig.bzl in the //rules package specifically. This makes it so we can create the stardoc target for these in one list vs. conditionalizing the path to the bzl_library

See this in docs/BUILD.bazel:

stardoc(
   ...
   input = "//rules:%s.bzl" % file,
)

@luispadron luispadron force-pushed the luis/update-stardoc-for-bzlmod branch 2 times, most recently from 61e7273 to 34ac987 Compare October 17, 2023 00:50
Base automatically changed from luis/use-bazel-skylib-write_file to master October 17, 2023 14:05
@luispadron luispadron force-pushed the luis/update-stardoc-for-bzlmod branch from 34ac987 to 412a316 Compare October 17, 2023 14:45
docs/BUILD.bazel Show resolved Hide resolved
"extension",
"features",
"force_load_direct_deps",
Copy link
Contributor

@jerrymarino jerrymarino Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A number of the files are internal ones we don't consider upholding an API contract for or have quality starlark doc comments about said internal components; though if other people really want to have this I'm not opposed - nor do I think it will change the lack of some API contract beyond apple_framework

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Features seems useful and imo more of the public API than some of the other things we've said are.

Do you have a specific list you'd want me to remove?

@luispadron luispadron force-pushed the luis/update-stardoc-for-bzlmod branch from 412a316 to 4fdb438 Compare October 18, 2023 14:41
Copy link
Contributor

@thiagohmcruz thiagohmcruz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx so much for tackling this!

docs/BUILD.bazel Outdated Show resolved Hide resolved
Co-authored-by: Thiago Cruz <thiago.hmcruz@gmail.com>
@luispadron luispadron merged commit b7b624b into master Oct 18, 2023
@luispadron luispadron deleted the luis/update-stardoc-for-bzlmod branch October 18, 2023 20:06
jerrymarino added a commit that referenced this pull request Oct 19, 2023
1. Export all files to `bzl_srcs`
2. Remove mirror of includes into `bzl_library`
3. Remove documentation of internal sources

Related: #783 #776
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants