Skip to content

Commit

Permalink
[docs] display preview warning and decorator info
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Jan 3, 2025
1 parent 18c3c18 commit 14520ec
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/content/about/releases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ The "experimental" marker allows us to offer new APIs to users and rapidly itera

Experimental APIs may change or disappear within any release, but we try to avoid breaking them within minor releases if they have been around for a long time.

### Preview APIs

The "preview" marker allows us to offer APIs in early testing phase to users and rapidly iterate based on their feedback. Preview APIs are marked as such in the [API reference](/\_apidocs) and usually raise an <PyObject object="PreviewWarning" module="dagster._utils.warnings" /> when used.

Experimental APIs may change or disappear within any release and are not considered ready for production use.

### Superseded APIs

The "superseded" marker indicates that we recommend avoiding an API, usually because there's a preferred option that should be used instead.
Expand Down
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.
1 change: 1 addition & 0 deletions docs/markdoc-component-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ We've also got a bunch of badges that you can use to indicate the level of suppo
There are the available badges:

- `{% experimental /%}` {% experimental /%}
- `{% preview /%}` {% preview /%}
- `{% deprecated /%}` {% deprecated /%}
- `{% superseded /%}` {% superseded /%}
- `{% legacy /%}` {% legacy /%}
Expand Down
8 changes: 8 additions & 0 deletions docs/next/components/markdoc/Badges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ export const Experimental = () => {
);
};

export const Preview = () => {
return (
<div className="preview-tag">
<span className="hidden">(</span>Preview<span className="hidden">)</span>
</div>
);
};

export const Deprecated = () => {
return (
<div className="deprecated-tag">
Expand Down
13 changes: 13 additions & 0 deletions docs/next/components/mdx/MDXComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,18 @@ const Experimental = () => {
);
};

////////////////////////
// Preview BADGE //
////////////////////////

const Preview = () => {
return (
<div className="preview-tag">
<span className="hidden">(</span>Preview<span className="hidden">)</span>
</div>
);
};

////////////////////////
// DEPRECATED BADGE //
////////////////////////
Expand Down Expand Up @@ -866,6 +878,7 @@ export default {
Experimental,
Deprecated,
Superseded,
Preview,
Legacy,
Icons,
ReferenceTable,
Expand Down
7 changes: 6 additions & 1 deletion docs/next/markdoc/tags.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ArticleList, ArticleListItem} from '../components/markdoc/ArticleList';
import {Badge, Experimental, Deprecated, Superseded, Legacy} from '../components/markdoc/Badges';
import {Badge, Experimental, Preview, Deprecated, Superseded, Legacy} from '../components/markdoc/Badges';
import {Button, ButtonContainer} from '../components/markdoc/Button';
import {Note, Warning} from '../components/markdoc/Callouts';
import {Check, Cross} from '../components/markdoc/CheckCross';
Expand Down Expand Up @@ -80,6 +80,11 @@ export const experimental = {
selfClosing: true,
};

export const preview = {
render: Preview,
selfClosing: true,
};

export const deprecated = {
render: Deprecated,
selfClosing: true,
Expand Down
Binary file modified docs/next/public/objects.inv
Binary file not shown.
4 changes: 4 additions & 0 deletions docs/next/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ dt > a.reference.internal {
@apply inline-flex items-center px-3 py-0.5 rounded-full align-middle text-xs uppercase font-medium bg-sea-foam text-gable-green
}

.preview-tag {
@apply inline-flex items-center px-3 py-0.5 rounded-full align-middle text-xs uppercase font-medium bg-gray-300 text-gray-900
}

.deprecated-tag {
@apply inline-flex items-center px-3 py-0.5 rounded-full align-middle text-xs uppercase font-medium bg-gray-300 text-gray-900
}
Expand Down
5 changes: 5 additions & 0 deletions docs/sphinx/_ext/dagster-sphinx/dagster_sphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
get_deprecated_params,
get_experimental_info,
get_experimental_params,
get_preview_info,
get_superseded_info,
has_deprecated_params,
has_experimental_params,
is_deprecated,
is_experimental,
is_preview,
is_public,
is_superseded,
)
Expand Down Expand Up @@ -126,6 +128,9 @@ def process_docstring(
if is_superseded(obj):
inject_object_flag(obj, get_superseded_info(obj), lines)

if is_preview(obj):
inject_object_flag(obj, get_preview_info(obj), lines)

if has_deprecated_params(obj):
params = get_deprecated_params(obj)
for param, info in params.items():
Expand Down
13 changes: 11 additions & 2 deletions docs/sphinx/_ext/dagster-sphinx/dagster_sphinx/docstring_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import dagster._check as check
import docutils.nodes as nodes
from dagster._annotations import DeprecatedInfo, ExperimentalInfo, SupersededInfo
from dagster._annotations import DeprecatedInfo, ExperimentalInfo, PreviewInfo, SupersededInfo

from sphinx.util.docutils import SphinxDirective

Expand All @@ -15,7 +15,9 @@


def inject_object_flag(
obj: object, info: Union[SupersededInfo, DeprecatedInfo, ExperimentalInfo], docstring: List[str]
obj: object,
info: Union[SupersededInfo, DeprecatedInfo, ExperimentalInfo, PreviewInfo],
docstring: List[str],
) -> None:
if isinstance(info, DeprecatedInfo):
additional_text = f" {info.additional_warn_text}." if info.additional_warn_text else ""
Expand All @@ -31,6 +33,13 @@ def inject_object_flag(
additional_text = f" {info.additional_warn_text}." if info.additional_warn_text else ""
flag_type = "superseded"
message = f"This API has been superseded and its usage is discouraged.\n{additional_text}"
elif isinstance(info, PreviewInfo):
additional_text = f" {info.additional_warn_text}." if info.additional_warn_text else ""
flag_type = "preview"
message = (
f"This is currently in preview, and may have breaking changes in patch version releases. "
f"This feature is not considered ready for production use.\n{additional_text}"
)
else:
check.failed(f"Unexpected info type {type(info)}")
for line in reversed([f".. flag:: {flag_type}", "", f" {message}", ""]):
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx/sections/api/apidocs/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Utilities

.. autoclass:: ExperimentalWarning

.. autoclass:: dagster._utils.warnings.PreviewWarning

.. autofunction:: make_email_on_run_failure_sensor

.. currentmodule:: dagster._utils.forked_pdb
Expand Down

0 comments on commit 14520ec

Please sign in to comment.