Skip to content

Commit

Permalink
Merge pull request #262 from machow/fix-member-options-tracking
Browse files Browse the repository at this point in the history
fix: setting member_options no longer unsets package on members
  • Loading branch information
machow authored Sep 1, 2023
2 parents 7339f4d + fdbc32a commit 1de0c38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 1 addition & 3 deletions quartodoc/builder/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ def _to_simple_dict(el: "BaseModel"):


def _non_default_entries(el: Auto):
d = el.dict()

return {k: d[k] for k in el._fields_specified}
return {k: getattr(el, k) for k in el._fields_specified}


class BlueprintTransformer(PydanticTransformer):
Expand Down
18 changes: 18 additions & 0 deletions quartodoc/tests/test_builder_blueprint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from quartodoc import get_object
from quartodoc import layout as lo
from quartodoc.builder.blueprint import (
_non_default_entries,
BlueprintTransformer,
blueprint,
WorkaroundKeyError,
Expand Down Expand Up @@ -37,6 +38,23 @@ def bp():
return BlueprintTransformer()


def test_non_default_entries_auto():
assert _non_default_entries(lo.Auto(name="a_func", include_attributes=False)) == {
"name": "a_func",
"include_attributes": False,
}


def test_non_default_entries_auto_member_options():
# these entries are nested inside auto
res = _non_default_entries(
lo.Auto(name="a_func", member_options={"include_attributes": False})
)

assert res["name"] == "a_func"
assert _non_default_entries(res["member_options"]) == {"include_attributes": False}


@pytest.mark.parametrize("path", ["quartodoc.get_object", "quartodoc:get_object"])
def test_blueprint_basic(bp, path):
auto = lo.Auto(name=path)
Expand Down

0 comments on commit 1de0c38

Please sign in to comment.