Skip to content

Commit

Permalink
[record] update __doc__ (#22952)
Browse files Browse the repository at this point in the history
so apidocs work

added test

`make apidoc-build`
` make next-watch-build`
load docs and ensure api entry for `DbtProject`
  • Loading branch information
alangenfeld committed Jul 11, 2024
1 parent 3b3e6a5 commit 65b894f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 6 deletions.
Binary file modified docs/content/api/modules.json.gz
Binary file not shown.
Binary file modified docs/content/api/searchindex.json.gz
Binary file not shown.
Binary file modified docs/content/api/sections.json.gz
Binary file not shown.
Binary file modified docs/next/public/objects.inv
Binary file not shown.
6 changes: 6 additions & 0 deletions docs/sphinx/_ext/dagster-sphinx/dagster_sphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
is_experimental,
is_public,
)
from dagster._record import get_original_class, is_record
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
from sphinx.ext.autodoc import (
Expand Down Expand Up @@ -86,6 +87,11 @@ class DagsterClassDocumenter(ClassDocumenter):
objtype = "class"

def get_object_members(self, want_all: bool) -> Tuple[bool, ObjectMembers]:
# the @record transform creates a new outer class, so redirect
# sphinx to target the original class for scraping members out of __dict__
if is_record(self.object):
self.object = get_original_class(self.object)

_, unfiltered_members = super().get_object_members(want_all)
# Use form `is_public(self.object, attr_name) if possible, because to access a descriptor
# object (returned by e.g. `@staticmethod`) you need to go in through
Expand Down
17 changes: 13 additions & 4 deletions python_modules/dagster/dagster/_record/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
_CHECKED_NEW = "__checked_new__"
_DEFAULTS_NEW = "__defaults_new__"
_INJECTED_DEFAULT_VALS_LOCAL_VAR = "__dm_defaults__"
_ORIGINAL_CLASS_FIELD = "__original_class__"


def _namedtuple_model_transform(
Expand Down Expand Up @@ -114,15 +115,17 @@ def _namedtuple_model_transform(
_RECORD_MARKER_FIELD: _RECORD_MARKER_VALUE,
_RECORD_ANNOTATIONS_FIELD: field_set,
"__nt_new__": nt_new,
_ORIGINAL_CLASS_FIELD: cls,
"__bool__": _true,
"__reduce__": _reduce,
# functools doesn't work, so manually update_wrapper
"__module__": cls.__module__,
"__qualname__": cls.__qualname__,
"__annotations__": field_set,
"__doc__": cls.__doc__,
},
)

# functools doesn't work, so manually update_wrapper
new_type.__module__ = cls.__module__
new_type.__qualname__ = cls.__qualname__

return new_type # type: ignore


Expand Down Expand Up @@ -247,9 +250,15 @@ def has_generated_new(obj) -> bool:


def get_record_annotations(obj) -> Mapping[str, Type]:
check.invariant(is_record(obj), "Only works for @record decorated classes")
return getattr(obj, _RECORD_ANNOTATIONS_FIELD)


def get_original_class(obj):
check.invariant(is_record(obj), "Only works for @record decorated classes")
return getattr(obj, _ORIGINAL_CLASS_FIELD)


def as_dict(obj) -> Mapping[str, Any]:
"""Creates a dict representation of a model."""
if not is_record(obj):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,11 @@ def _some_func():
@record
class _(Base):
thing: Any = _some_func


def test_docs():
@record
class Documented:
"""So much to know about this class."""

assert Documented.__doc__
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class DbtProject(IHaveNew):
Using this helps achieve a setup where the dbt manifest file
and dbt dependencies are available and up-to-date:
* during development, pull the dependencies and reload the manifest at run time to pick up any changes.
* when deployed, expect a manifest that was created at build time to reduce start-up time.
* during development, pull the dependencies and reload the manifest at run time to pick up any changes.
* when deployed, expect a manifest that was created at build time to reduce start-up time.
The cli ``dagster-dbt project prepare-and-package`` can be used as part of the deployment process to
handle the project preparation.
Expand Down

1 comment on commit 65b894f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagster-docs ready!

✅ Preview
https://dagster-docs-evds3kf6b-elementl.vercel.app
https://release-1-7-13.dagster.dagster-docs.io

Built with commit 65b894f.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.