Skip to content

Commit

Permalink
Display warnings for deprecated schemata and properties (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillprochaska authored Jul 24, 2023
1 parent 41a5fbb commit 05d501f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
14 changes: 7 additions & 7 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@alephdata/followthemoney": "^3.2.1",
"@alephdata/followthemoney": "^3.5.1",
"@astrojs/markdown-component": "^1.0.2",
"astro": "^1.4.3",
"astro-theme-docs": "github:alephdata/astro-theme-docs",
Expand Down
30 changes: 30 additions & 0 deletions docs/src/components/explorer/DeprecatedIndicator.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
import { Popover } from 'astro-theme-docs/components';
const { message } = Astro.props;
---

<style>
.DeprecatedIndicator {
display: inline-block;
padding-inline: var(--space-xs);

color: var(--color-fg-negative);
background-color: var(--color-bg-negative);
border: 1px solid var(--color-border-negative);
border-radius: var(--radius-full);

font-size: calc(0.85 * var(--font-size-sm));
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.1em;

cursor: default;
}
</style>

<Popover>
<span class="DeprecatedIndicator"> Deprecated</span>
<p slot="content">
{message}
</p>
</Popover>
8 changes: 5 additions & 3 deletions docs/src/components/explorer/SchemaProperties.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import PropertyType from '@components/explorer/PropertyType.astro';
import SchemaLink from '@components/explorer/SchemaLink.astro';
import IndexTable from '@components/explorer/IndexTable.astro';
import PropertyIndicator from '@components/explorer/PropertyIndicator.astro';
import DeprecatedIndicator from '@components/explorer/DeprecatedIndicator.astro';
const { schema, ...rest } = Astro.props;
const isFeatured = (property) =>
property.schema.featured.includes(property.name);
const isRequired = (property) =>
property.schema.required.includes(property.name);
const isHidden = (property) => property.hidden;
const isInherited = (property) => property.schema.name !== schema.name;
const isDeprecated = (property) => property.deprecated;
const properties = Array.from(schema.getProperties().values())
.sort((a, b) => a.name.localeCompare(b.name))
Expand Down Expand Up @@ -82,6 +81,9 @@ const properties = Array.from(schema.getProperties().values())
{isFeatured(prop) && <PropertyIndicator type="featured" />}
{isRequired(prop) && <PropertyIndicator type="required" />}
{isHidden(prop) && <PropertyIndicator type="hidden" />}
{isDeprecated(prop) && (
<DeprecatedIndicator message="This property is deprecated and will be removed in a future version of the FollowTheMoney model." />
)}
</td>

<td>{prop.label}</td>
Expand Down
4 changes: 4 additions & 0 deletions docs/src/components/explorer/SchemataIndexTable.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { model } from '@util/ftm';
import IndexTable from '@components/explorer/IndexTable.astro';
import SchemaLink from '@components/explorer/SchemaLink.astro';
import BooleanValue from '@components/explorer/BooleanValue.astro';
import DeprecatedIndicator from '@components/explorer/DeprecatedIndicator.astro';
const schemata = Object.values(model.schemata).sort((a, b) =>
a.label.localeCompare(b.label)
Expand All @@ -23,6 +24,9 @@ const schemata = Object.values(model.schemata).sort((a, b) =>
<SchemaLink {schema}>
<code>{schema.name}</code>
</SchemaLink>
{schema.deprecated && (
<DeprecatedIndicator message="This schema is deprecated and will be removed in a future version of the FollowTheMoney model." />
)}
</td>
<td>{schema.label}</td>
<td>
Expand Down
10 changes: 9 additions & 1 deletion docs/src/pages/explorer/schemata/[name].astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { model } from '@util/ftm';
import { Stack, TocNav } from 'astro-theme-docs/components';
import { Stack, TocNav, Callout } from 'astro-theme-docs/components';
import ExplorerLayout from '@layouts/ExplorerLayout.astro';
import SchemaPageHeader from '@components/page/SchemaPageHeader.astro';
import SchemaInheritance from '@components/explorer/SchemaInheritance.astro';
Expand Down Expand Up @@ -29,6 +29,14 @@ const headings = [

<Stack size="xl">
<SchemaPageHeader schema={schema} />
{
schema.deprecated && (
<Callout theme="danger">
This schema is deprecated and will be removed in a future version of
the FollowTheMoney model.
</Callout>
)
}
<SchemaInheritance id="inheritance" schema={schema} />
<SchemaSemantics id="semantics" schema={schema} />
<SchemaProperties id="properties" schema={schema} />
Expand Down

0 comments on commit 05d501f

Please sign in to comment.