Skip to content

Commit 7a5bbe2

Browse files
authored
Allow "none" in autodoc (#455)
* Allow "none" in autodoc * Add tests ensuring that "none" doesn't add anchors
1 parent 7bcc3eb commit 7a5bbe2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/doc_builder/autodoc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ def autodoc(object_name, package, methods=None, return_anchors=False, page_info=
492492
methods.remove("all")
493493
methods_to_add = find_documented_methods(obj)
494494
methods.extend([m for m in methods_to_add if m not in methods])
495+
elif "none" in methods:
496+
methods = []
495497
for method in methods:
496498
anchor_name = f"{anchors[0]}.{method}"
497499
method_doc, check = document_object(

tests/test_autodoc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ def test_autodoc_return_anchors(self):
324324
],
325325
)
326326

327+
_, anchors, _ = autodoc("BertTokenizer", transformers, methods=["none"], return_anchors=True)
328+
self.assertListEqual(anchors, ["transformers.BertTokenizer"])
329+
330+
_, anchors, _ = autodoc("BertTokenizer", transformers, methods=["none", "__call__"], return_anchors=True)
331+
self.assertListEqual(anchors, ["transformers.BertTokenizer"])
332+
327333
_, anchors, _ = autodoc("BertTokenizer", transformers, methods=["__call__"], return_anchors=True)
328334
self.assertListEqual(
329335
anchors,

0 commit comments

Comments
 (0)