Skip to content

Commit 9edda48

Browse files
authored
Merge pull request #372 from machow/feat-auto-exclude
feat: implement auto excludes option
2 parents 62759f0 + 90d83d3 commit 9edda48

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

quartodoc/builder/blueprint.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,6 @@ def _fetch_members(self, el: Auto, obj: dc.Object | dc.Alias):
371371
if obj.is_module and obj.exports is not None:
372372
options = {k: v for k, v in options.items() if v.is_exported}
373373

374-
if el.include:
375-
raise NotImplementedError("include argument currently unsupported.")
376-
377-
if el.exclude:
378-
raise NotImplementedError("exclude argument currently unsupported.")
379-
380374
if not el.include_private:
381375
options = {k: v for k, v in options.items() if not k.startswith("_")}
382376

@@ -407,6 +401,12 @@ def _fetch_members(self, el: Auto, obj: dc.Object | dc.Alias):
407401
if not el.include_functions:
408402
options = {k: v for k, v in options.items() if not v.is_function}
409403

404+
if el.include:
405+
raise NotImplementedError("include argument currently unsupported.")
406+
407+
if el.exclude:
408+
options = {k: v for k, v in options.items() if k not in el.exclude}
409+
410410
if el.member_order == "alphabetical":
411411
return sorted(options)
412412
elif el.member_order == "source":

quartodoc/layout.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class AutoOptions(_Base):
221221

222222
# other options ----
223223
include: Optional[str] = None
224-
exclude: Optional[str] = None
224+
exclude: Optional[list[str]] = None
225225
dynamic: Union[None, bool, str] = None
226226
children: ChoicesChildren = ChoicesChildren.embedded
227227
package: Union[str, None, MISSING] = MISSING()
@@ -250,6 +250,7 @@ class Auto(AutoOptions):
250250
path the object, and short is the name of the object (i.e. no periods).
251251
members:
252252
A list of members, such as attributes or methods on a class, to document.
253+
If members is specified, no other includes or excludes are applied.
253254
include_private:
254255
Whether to include members starting with "_"
255256
include_imports:
@@ -267,7 +268,8 @@ class Auto(AutoOptions):
267268
include:
268269
(Not implemented). A list of members to include.
269270
exclude:
270-
(Not implemented). A list of members to exclude.
271+
A list of members to exclude. This is performed last, in order to subtract
272+
from the results of options like include_functions.
271273
dynamic:
272274
Whether to dynamically load docstring. By default docstrings are loaded
273275
using static analysis. dynamic may be a string pointing to another object,

quartodoc/tests/test_builder_blueprint.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,30 @@ def test_blueprint_fetch_members_include_inherited():
245245
assert "some_method" in member_names
246246

247247

248+
def test_blueprint_fetch_members_exclude():
249+
auto = lo.Auto(
250+
name="quartodoc.tests.example_class.C",
251+
include_functions=True,
252+
include_attributes=False,
253+
include_classes=False,
254+
exclude=["some_property", "some_class_method"],
255+
)
256+
257+
bp = blueprint(auto)
258+
_check_member_names(bp.members, {"some_method"})
259+
260+
261+
def test_blueprint_fetch_members_exclude_ignored():
262+
auto = lo.Auto(
263+
name="quartodoc.tests.example_class.C",
264+
members=["some_property", "some_class_method"],
265+
exclude=["some_class_method"],
266+
)
267+
268+
bp = blueprint(auto)
269+
_check_member_names(bp.members, {"some_property", "some_class_method"})
270+
271+
248272
def test_blueprint_fetch_members_dynamic():
249273
# Since AClass is imported via star import it has to be dynamically
250274
# resolved. This test ensures that the members of AClass also get

0 commit comments

Comments
 (0)