Skip to content

Commit 4a835aa

Browse files
author
Erica Sadun
committed
EDU-4420: Adds audit-stray-pages and updates READMEs
1 parent efd3d18 commit 4a835aa

File tree

5 files changed

+168
-35
lines changed

5 files changed

+168
-35
lines changed

COMPONENTS.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Whether you’re using core components or experimenting with new ones, this guid
2121
- [Using CaptionedImage](#using-captionedimage)
2222
- [Using DiscoverableDisclosure](#using-discoverabledisclosure)
2323
- [Using DocsTable](#using-docstable)
24+
- [Using PhotoCarousel](#using-photocarousel)
2425
- [Using RelatedRead](#using-relatedread)
2526
- [Using ToolTipTerm](#using-tooltipterm)
2627
- [Using ZoomingImage](#using-zoomingimage)
@@ -39,39 +40,6 @@ Our components are located in the `src/components` folder at the root of this re
3940
- **`experimental`**: This folder contains components that are not currently used on the site.
4041
These are either for testing or were previously part of ongoing development.
4142

42-
```
43-
components
44-
├── elements
45-
│   ├── Button.js
46-
│   ├── Intro.js
47-
│   ├── PhotoCarousel.js
48-
│   ├── RetrySimulator.js
49-
│   ├── SdkLogos.js
50-
│   └── retry-simulator.module.css
51-
├── experimental
52-
│   ├── CenteredImage.js
53-
│   ├── CustomWarning.js
54-
│   ├── DetermineHeader.js
55-
│   ├── InfoButton.js
56-
│   ├── NoBreak.js
57-
│   ├── ResponsivePlayer.js
58-
│   ├── RowOfImages.js
59-
│   ├── Spacer.js
60-
│   └── ToolTipText.js
61-
├── formatting
62-
│   └── DocsTable.js
63-
├── images
64-
│   ├── CaptionedImage.js
65-
│   └── CaptionedImage.module.css
66-
├── index.js
67-
└── info
68-
├── DiscoverableDisclosure.js
69-
├── RelatedRead.js
70-
├── RelatedRead.module.css
71-
├── RelatedReadList.js
72-
└── ToolTipTerm.js
73-
```
74-
7543
Components are reusable, self-contained units of code used for our Documentation site.
7644
As shown in this file tree, our components are built using JavaScript and React.
7745
Components often have associated CSS files to manage styling, although this is optional.
@@ -262,6 +230,44 @@ Archetypes:
262230
- feature-guide
263231
- feature-summary
264232

233+
## Using PhotoCarousel
234+
235+
Role: Provide annotated walk-through using an image carousel presentation with text.
236+
237+
How to import:
238+
239+
```
240+
import { PhotoCarousel } from '@site/src/components';
241+
```
242+
243+
or
244+
245+
```
246+
import PhotoCarousel from "@site/src/components/elements/PhotoCarousel";
247+
```
248+
249+
Usage:
250+
251+
```
252+
<PhotoCarousel
253+
images={[
254+
"/link/to/image-1",
255+
"/link/to/image-2",
256+
...
257+
]}
258+
captions={[
259+
"caption-1",
260+
"caption-2",
261+
...
262+
]}
263+
/>
264+
```
265+
266+
- If links are stored on-site, place images in static in an appropriately themed folder.
267+
- If links are stored off-site, use a fully specified URL
268+
- Please ensure the caption count and order matches that of the images
269+
- You may pass an optional `isDarkMode` Boolean prop
270+
265271
## Using ToolTipTerm
266272

267273
Role: Provide definitions or background information at the point of use.

READABILITY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Readability Tools
22

33
This repository includes a small set of utilities to support content readability.
4+
These utilities are not meant for use by contributors.
5+
46
All tools are Bash scripts, located in the `bin/` directory at the root of this repository.
57
These scripts help review and transform content to improve documentation processing.
68
They are lightweight and designed to work within the content-creation and content-evaluation workflow.

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ Welcome to Temporal's documentation repository!
66

77
This repository contains a large chunk of the Temporal information corpus.
88

9-
- [Contributing guidance](./CONTRIBUTING.md)
10-
- [Style guidance](./STYLE.md)
9+
| Resource | Audience |
10+
|--------------------------------------------|--------------------------|
11+
| [Contact information](./CONTACT.md) | For our open source community |
12+
| [Contributing guidance](./CONTRIBUTING.md) | For our open source community |
13+
| [License](./LICENSE.md) | For our open source community |
14+
| [React Component catalog and guidance](./COMPONENTS.md) | For our open source community |
15+
| [Readability tooling guidance](./READABILITY.md) | For repo maintainers |
16+
| [Style guidance](./STYLE.md) | For our open source community |
17+
| [Utility tooling guidance](./UTILITIES.md) | For repo maintainers |
1118

1219
### Current component versioning philosophy
1320

UTILITIES.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Temporal Documentation Site Utilities
2+
3+
This file documents utilities meant to support repository health.
4+
These utilities are not meant for use by contributors.
5+
6+
## audit-stray-pages
7+
8+
[**Docusaurus**](https://docusaurus.io) serves all files, whether they are mentioned in sidebars.js or not.
9+
[**Algolia**](https://algolia.com) will index these files so they show up in search, even though we intend to hide them.
10+
11+
The `audit-stray-pages` utility audits unreferenced docs files so they can be evaluated and, if needed, hidden in Docusaurus.
12+
This script scans your Docusaurus project for `.md` and `.mdx` files in the top level `docs/` folder and reports the ones that are **not actively referenced** in your `sidebars.js` file. "Not actively referenced" includes:
13+
14+
- Files that were commented out in sidebars.js
15+
- Files that are not included at all
16+
17+
It helps you find:
18+
19+
- Stray or deprecated documentation pages that aren’t in the site navigation
20+
- Files that are publicly accessible but unintentionally published
21+
- Gaps in `id:` usage where default IDs don’t match sidebar references
22+
23+
You can hide Docusaurus files by setting them to drafts in the file metadata:
24+
25+
```
26+
draft: true
27+
```
28+
29+
Docusaurus will render drafts in preview mode but not production.
30+
31+
**Please note**:
32+
33+
- Some "deprecated" files are left intentionally visible outside the normal navigation system and are linked from other pages.
34+
They should not be set to draft as that breaks `yarn build` and will fail CI and Vercel deployment.
35+
- The sidebars.js file does not use `/path/to/file.mdx`.
36+
It uses `/path/to/folder/your-file-id`, which uses the `id: your-file-id` declared in your mdx YAML frontmatter.
37+
- Slugs are not equivalent to ids.
38+
Ids are used to stitch together the site.
39+
40+
### What It Does
41+
42+
1. **Parses `sidebars.js`** to extract all actively referenced doc IDs
43+
- Ignores lines that are commented out (`//` or `/* ... */`)
44+
2. **Extracts doc IDs** from sidebar references, including:
45+
- Simple string references: `"foo/bar"`
46+
- Object syntax: `{ type: 'doc', id: 'foo/bar' }`
47+
3. **Scans all `.md` and `.mdx` files** in the `docs/` directory:
48+
- First checks if the file's path-derived ID is in the sidebar
49+
- Then checks for a frontmatter `id:` override and searches that
50+
- If neither is found, the file is flagged as unreferenced
51+
52+
### Usage
53+
54+
Save the script as `audit-stray-pages` and make it executable:
55+
56+
```bash
57+
chmod +x audit-stray-pages
58+
./audit-stray-pages
59+
```
60+
61+
### Work
62+
63+
After running the script, review each unreferenced file carefully.
64+
65+
- Some files may be intentionally excluded from the sidebar, such as deprecated pages or internal drafts.
66+
- Others may be unintentional omissions that should be added to sidebars.js.
67+
- Others are intentionally excluded but not referenced from anywhere on the site.
68+
This is deliberate in the case of `tctl` pages.
69+
This is accidental for other pages.
70+
71+
For each flagged file, check whether it:
72+
73+
- Should be deleted or archived
74+
- Should have a `draft: true` frontmatter added (Docusaurus v3+)
75+
- Needs a matching `id:` in the frontmatter
76+
- Belongs in `sidebars.js` but was accidentally left out or commented out
77+
78+
This utility highlights potential issues—it’s up to you to decide what belongs in our published documentation.

bin/audit-stray-pages

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
SIDEBARS_FILE="sidebars.js"
4+
CLEANED_SIDEBAR="/tmp/cleaned_sidebars.txt"
5+
6+
# 1. Preprocess sidebars.js
7+
# Remove // comments and /* block comments */
8+
sed '/^\s*\/\//d' "$SIDEBARS_FILE" | sed '/\/\*/,/\*\//d' > "$CLEANED_SIDEBAR"
9+
10+
# 2. Extract IDs from cleaned sidebars
11+
# IDs can appear like "foo/bar" or id: "foo/bar"
12+
grep -oE '"[^"]+"' "$CLEANED_SIDEBAR" | tr -d '"' | sort | uniq > /tmp/sidebar_ids.txt
13+
14+
# 3. Now audit all docs
15+
find docs \( -name "*.mdx" -o -name "*.md" \) | while read -r filepath; do
16+
# Get default ID
17+
default_id=$(echo "$filepath" | sed -E 's|^docs/||;s|\.mdx$||;s|\.md$||')
18+
19+
# Check if default_id is in the sidebar IDs
20+
if grep -qxF "$default_id" /tmp/sidebar_ids.txt; then
21+
continue
22+
fi
23+
24+
# If not found, check for custom ID
25+
custom_id=$(grep -m 1 '^id:' "$filepath" | sed 's/id:[[:space:]]*//' | tr -d '\r')
26+
if [ -n "$custom_id" ]; then
27+
custom_id=$(echo "$custom_id" | xargs)
28+
if grep -qxF "$custom_id" /tmp/sidebar_ids.txt; then
29+
continue
30+
fi
31+
fi
32+
33+
# Neither found — this is a potential stray file
34+
# Removing something linked but deprecated will break the build
35+
# Prefer to remove intentional items (commented out in sidebars.js)
36+
# Investigate items that may be unintentional.
37+
# Try to add slugs to all affected files that match the file names
38+
# and search for those
39+
echo "$filepath"
40+
done

0 commit comments

Comments
 (0)