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

Commit 0713d0e

Browse files
committed
Add stub for load() to support Skylark sources that load other .bzl files.
-- MOS_MIGRATED_REVID=124985756
1 parent b5f9b6a commit 0713d0e

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

skydoc/macro_extractor_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,5 +395,13 @@ def test_file_doc_title_multiline(self):
395395
'\n\nDocumentation continued here.',
396396
extractor.description)
397397

398+
def test_loads_ignored(self):
399+
src = textwrap.dedent("""\
400+
load("//foo/bar:baz.bzl", "foo_library")
401+
load("//foo/bar:baz.bzl", "foo_test", orig_foo_binary = "foo_binary")
402+
""")
403+
expected = ''
404+
self.check_protos(src, expected)
405+
398406
if __name__ == '__main__':
399407
unittest.main()

skydoc/rule_extractor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"struct": skylark_globals.struct,
3838
"repository_rule": skylark_globals.repository_rule,
3939
"rule": skylark_globals.rule,
40+
"load": skylark_globals.load,
4041
}
4142
"""Stubs for Skylark globals to be used to evaluate the .bzl file."""
4243

skydoc/rule_extractor_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,13 @@ def _impl(ctx):
504504

505505
self.check_protos(src, expected)
506506

507+
def test_loads_ignored(self):
508+
src = textwrap.dedent("""\
509+
load("//foo/bar:baz.bzl", "foo_library")
510+
load("//foo/bar:baz.bzl", "foo_test", orig_foo_binary = "foo_binary")
511+
""")
512+
expected = ''
513+
self.check_protos(src, expected)
514+
507515
if __name__ == '__main__':
508516
unittest.main()

skydoc/stubs/skylark_globals.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ def select(x):
3636
def struct(**kwargs):
3737
return None
3838

39+
# TODO(dzc): As a future improvement, consider whether we want to evaluate loads
40+
# in .bzl files and provide links to the rules or macros in the .bzl files
41+
# being loaded. To do so, we would also have to require that all .bzl
42+
# dependencies are being included for the skylark_doc target.
43+
def load(label, *args, **kwargs):
44+
return None
45+
3946
class Label(object):
4047
def __init__(self, label_string):
4148
self.label_string = label_string

0 commit comments

Comments
 (0)