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

Commit

Permalink
Add stub for load() to support Skylark sources that load other .bzl f…
Browse files Browse the repository at this point in the history
…iles.

--
MOS_MIGRATED_REVID=124985756
  • Loading branch information
davidzchen committed Jun 15, 2016
1 parent b5f9b6a commit 0713d0e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions skydoc/macro_extractor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,5 +395,13 @@ def test_file_doc_title_multiline(self):
'\n\nDocumentation continued here.',
extractor.description)

def test_loads_ignored(self):
src = textwrap.dedent("""\
load("//foo/bar:baz.bzl", "foo_library")
load("//foo/bar:baz.bzl", "foo_test", orig_foo_binary = "foo_binary")
""")
expected = ''
self.check_protos(src, expected)

if __name__ == '__main__':
unittest.main()
1 change: 1 addition & 0 deletions skydoc/rule_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"struct": skylark_globals.struct,
"repository_rule": skylark_globals.repository_rule,
"rule": skylark_globals.rule,
"load": skylark_globals.load,
}
"""Stubs for Skylark globals to be used to evaluate the .bzl file."""

Expand Down
8 changes: 8 additions & 0 deletions skydoc/rule_extractor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,5 +504,13 @@ def _impl(ctx):

self.check_protos(src, expected)

def test_loads_ignored(self):
src = textwrap.dedent("""\
load("//foo/bar:baz.bzl", "foo_library")
load("//foo/bar:baz.bzl", "foo_test", orig_foo_binary = "foo_binary")
""")
expected = ''
self.check_protos(src, expected)

if __name__ == '__main__':
unittest.main()
7 changes: 7 additions & 0 deletions skydoc/stubs/skylark_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def select(x):
def struct(**kwargs):
return None

# TODO(dzc): As a future improvement, consider whether we want to evaluate loads
# in .bzl files and provide links to the rules or macros in the .bzl files
# being loaded. To do so, we would also have to require that all .bzl
# dependencies are being included for the skylark_doc target.
def load(label, *args, **kwargs):
return None

class Label(object):
def __init__(self, label_string):
self.label_string = label_string
Expand Down

0 comments on commit 0713d0e

Please sign in to comment.