Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Unexpected keyword argument 'relative_to_caller_repository' #45

Closed
jayconrod opened this issue Mar 6, 2017 · 3 comments
Closed

Unexpected keyword argument 'relative_to_caller_repository' #45

jayconrod opened this issue Mar 6, 2017 · 3 comments

Comments

@jayconrod
Copy link

jayconrod commented Mar 6, 2017

I'm interested in trying skydoc for github.com/bazelbuild/rules_go. Maybe we can generate part of our README.md from doc comments in our go/def.bzl file.

I imported Skydoc by adding this to WORKSPACE:

# Documentation generation
git_repository(
    name = "io_bazel_rules_sass",
    remote = "https://github.com/bazelbuild/rules_sass.git",
    tag = "0.0.2",
)
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_repositories")
sass_repositories()

git_repository(
    name = "io_bazel_skydoc",
    remote = "https://github.com/bazelbuild/skydoc",
    tag = "0.1.3",
)
load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")
skydoc_repositories()

I added a BUILD file with this:

load("@io_bazel_skydoc//skylark:skylark.bzl", "skylark_doc")

skylark_doc(
    name = "docs",
    srcs = ["def.bzl"],
)

When I run bazel build go:docs, I get the following error:

ERROR: /usr/local/google/home/jayconrod/Code/rules_go/go/BUILD:3:1: Generating Skylark doc for docs (1 files) failed: Process exited with status 1 [sandboxed].
Traceback (most recent call last):
  File "/usr/local/google/home/jayconrod/.cache/bazel/_bazel_jayconrod/05c35472541ec3c4670f66aa89b6cabb/bazel-sandbox/119b7aa7-9ac7-481d-bd96-6aabd55c18c8-0/execroot/rules_go/bazel-out/host/bin/external/io_bazel_skydoc/skydoc/skydoc.runfiles/io_bazel_rules_go/../io_bazel_skydoc/skydoc/main.py", line 330, in <module>
    main(FLAGS(sys.argv))
  File "/usr/local/google/home/jayconrod/.cache/bazel/_bazel_jayconrod/05c35472541ec3c4670f66aa89b6cabb/bazel-sandbox/119b7aa7-9ac7-481d-bd96-6aabd55c18c8-0/execroot/rules_go/bazel-out/host/bin/external/io_bazel_skydoc/skydoc/skydoc.runfiles/io_bazel_rules_go/../io_bazel_skydoc/skydoc/main.py", line 308, in main
    rule_doc_extractor.parse_bzl(bzl_file, load_symbols)
  File "/usr/local/google/home/jayconrod/.cache/bazel/_bazel_jayconrod/05c35472541ec3c4670f66aa89b6cabb/bazel-sandbox/119b7aa7-9ac7-481d-bd96-6aabd55c18c8-0/execroot/rules_go/bazel-out/host/bin/external/io_bazel_skydoc/skydoc/skydoc.runfiles/io_bazel_skydoc/skydoc/rule_extractor.py", line 227, in parse_bzl
    self._process_skylark(bzl_file, load_symbols)
  File "/usr/local/google/home/jayconrod/.cache/bazel/_bazel_jayconrod/05c35472541ec3c4670f66aa89b6cabb/bazel-sandbox/119b7aa7-9ac7-481d-bd96-6aabd55c18c8-0/execroot/rules_go/bazel-out/host/bin/external/io_bazel_skydoc/skydoc/skydoc.runfiles/io_bazel_skydoc/skydoc/rule_extractor.py", line 99, in _process_skylark
    exec(compiled) in global_stubs, skylark_locals
  File "go/def.bzl", line 554, in <module>
    relative_to_caller_repository = True,
TypeError: __init__() got an unexpected keyword argument 'relative_to_caller_repository'
Use --strategy=Skydoc=standalone to disable sandboxing for the failing actions.
blaze: Leaving directory `/usr/local/google/home/jayconrod/.cache/bazel/_bazel_jayconrod/05c35472541ec3c4670f66aa89b6cabb/execroot/rules_go/'
Target //go:docs failed to build
Use --verbose_failures to see the command lines of failed build steps.
____Elapsed time: 1.820s, Critical Path: 0.69s

It looks like Skydoc isn't recognizing the relative_to_caller_repository keyword argument to Label. This is a documented parameter, but probably used infrequently. Maybe it would be better to ignore unknown parameters?

@davidzchen
Copy link
Member

@jayconrod - Sorry for the delay.

I will need to add a stub for this. We have plans to reimplement Skydoc in Java using the same Skylark interpreter, but for now, we need to manually add the Python stubs in Skydoc when new parameters and Skylark globals are added.

For my understanding of your use case, can you please paste a code example showing how you are using Label with this parameter in your .bzl file? Thanks!

@jayconrod
Copy link
Author

Sure, we use this when defining a default label for an attribute used in most of our rules. See go/def.bzl:663.

The idea is that every repository that declares Go rules must declare a go_prefix rule. All Go rules within that repository implicitly depend on that go_prefix rule. It's important that they depend on the go_prefix within their own repository and not the one declared with the Go rules.

@davidzchen
Copy link
Member

Thanks! Just sent a pull request: #46

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants