Skip to content

Commit 0136eda

Browse files
authored
Merge pull request #596 from adobe/docs
Initial Docusaurus Setup
2 parents ce2cf7c + cbad994 commit 0136eda

File tree

93 files changed

+9965
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+9965
-123
lines changed

.github/workflows/pr-checks.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ jobs:
5050
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
5151
run: yarn build:storybook
5252

53+
- name: Build Docs
54+
# Don't run Storybook build on PRs from forks
55+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
56+
run: |
57+
echo "Current content of docusaurus.config.ts:"
58+
cat packages/docs/docusaurus.config.ts
59+
# modify the docusaurus.config.ts, changing the baseUrl to /react-spectrum-charts/PR-${{ github.event.number }}-docs/
60+
sed -i 's|baseUrl: '"'"'/react-spectrum-charts/docs/'"'"'|baseUrl: '"'"'/react-spectrum-charts/PR-${{ github.event.number }}-docs/'"'"'|g' packages/docs/docusaurus.config.ts
61+
echo "Content after sed command:"
62+
cat packages/docs/docusaurus.config.ts
63+
# build the docs
64+
yarn build:docs
65+
# revert the docusaurus.config.ts
66+
git checkout packages/docs/docusaurus.config.ts
67+
5368
- name: Create and Upload Storybook to PR directory
5469
# Don't run Storybook upload on PRs from forks
5570
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
@@ -67,29 +82,60 @@ jobs:
6782
6883
# Remove the PR directory if it exists
6984
rm -rf "${PR_NUMBER}"
85+
rm -rf "${PR_NUMBER}-docs"
7086
7187
# Create the PR directory
7288
mkdir "${PR_NUMBER}"
89+
mkdir "${PR_NUMBER}-docs"
7390
7491
# Copy the contents of dist-storybook to the directory
7592
cp -r dist-storybook/* "${PR_NUMBER}/"
93+
cp -r packages/docs/dist/* "${PR_NUMBER}-docs/"
7694
7795
rm -rf node_modules # Explicitly remove the node_modules directory
7896
rm -rf dist-storybook # Explicitly remove the dist-storybook directory
7997
8098
# Add, commit, and push changes
8199
git add "${PR_NUMBER}/."
82-
git commit -m "Update Storybook for ${PR_NUMBER}"
100+
git add "${PR_NUMBER}-docs/."
101+
git commit -m "Update Storybook and Docs for ${PR_NUMBER}"
83102
git push -f origin gh-pages
84103
env:
85104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86105

87-
- name: Add comment to the PR with Storybook URL
106+
- name: Delete Storybook URL and Docs URL comment if it exists
107+
# Don't delete comment on PRs from forks
108+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
109+
run: |
110+
PR_NUMBER="${{ github.event.number }}"
111+
112+
# Find comments with the Storybook URL and Docs URL
113+
COMMENT_IDS=$(curl -sSL \
114+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
115+
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" | \
116+
jq -r '.[] | select(.body | contains("🎨 Storybook ->") or contains("📚 Docs ->")) | .id')
117+
118+
# Check if we found any comments
119+
if [ ! -z "$COMMENT_IDS" ]; then
120+
echo "Found matching comments to delete"
121+
# Loop through each comment ID
122+
echo "$COMMENT_IDS" | while read -r COMMENT_ID; do
123+
echo "Deleting comment with ID: $COMMENT_ID"
124+
curl -sSL \
125+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
126+
-X DELETE \
127+
"https://api.github.com/repos/${{ github.repository }}/issues/comments/${COMMENT_ID}"
128+
done
129+
else
130+
echo "No matching comments found to delete"
131+
fi
132+
133+
- name: Add comment to the PR with Storybook URL and Docs URL
88134
# Don't add comment on PRs from forks
89135
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
90136
run: |
91137
PR_NUMBER="${{ github.event.number }}"
92-
COMMENT_BODY="🎨 Storybook -> https://opensource.adobe.com/react-spectrum-charts/PR-${PR_NUMBER}"
138+
COMMENT_BODY="🎨 Storybook -> https://opensource.adobe.com/react-spectrum-charts/PR-${PR_NUMBER}\n\n📚 Docs -> https://opensource.adobe.com/react-spectrum-charts/PR-${PR_NUMBER}-docs/"
93139
94140
curl -sSL \
95141
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \

.github/workflows/publish-prod-storybook.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Storybook to GitHub Pages
1+
name: Publish Storybook and Docs to GitHub Pages
22
# This action runs when a branch has been merged to main.
33

44
on:
@@ -32,6 +32,9 @@ jobs:
3232
- name: Build Storybook
3333
run: yarn build:storybook
3434

35+
- name: Build Docs
36+
run: yarn build:docs
37+
3538
- name: Checkout and clean current 'gh-pages' branch
3639
run: |
3740
git config user.name "marshallpete"
@@ -56,6 +59,10 @@ jobs:
5659
run: |
5760
cp -r dist-storybook/* .
5861
62+
- name: Copy 'dist' to 'gh-pages' branch
63+
run: |
64+
cp -r packages/docs/dist/* ./docs
65+
5966
- name: Commit and push changes to 'gh-pages' branch
6067
run: |
6168
git add -- . ':!dist-storybook'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ test-report.xml
2626
# cursor
2727
cursor
2828
.cursor
29+
30+
# docusaurus
31+
.docusaurus

.prettierrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"tabWidth": 4,
3-
"useTabs": true,
2+
"tabWidth": 2,
3+
"useTabs": false,
44
"printWidth": 120,
55
"singleQuote": true,
66
"importOrder": [

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
![Scatter plot of penguin bill dimensions by species and body mass](https://github.com/adobe/react-spectrum-charts/wiki/images/penguins.png)
1616

17+
## Documentation
18+
19+
[React Spectrum Charts documentation](https://opensource.adobe.com/react-spectrum-charts/docs)
20+
1721
## Table of Contents
1822

1923
- [React Spectrum Charts](#react-spectrum-charts)
@@ -62,6 +66,11 @@ npm install @adobe/react-spectrum-charts @adobe/react-spectrum vega vega-lite
6266
yarn add @adobe/react-spectrum-charts @adobe/react-spectrum vega vega-lite
6367
```
6468

69+
#### pnpm
70+
```bash
71+
pnpm add @adobe/react-spectrum-charts @adobe/react-spectrum vega vega-lite
72+
```
73+
6574
## Usage
6675

6776
`react-spectrum-charts` is designed in a way that makes composing charts similar to composing any other app content in JSX.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"scripts": {
6060
"build": "yarn workspaces run build",
6161
"build:parallel": "concurrently 'yarn workspace @spectrum-charts/themes build' 'yarn workspace @spectrum-charts/constants build' 'yarn workspace @spectrum-charts/utils build' 'yarn workspace @spectrum-charts/locales build' && yarn workspace @spectrum-charts/vega-spec-builder build && yarn workspace @adobe/react-spectrum-charts build",
62+
"build:docs": "yarn workspace @spectrum-charts/docs build",
6263
"clean": "yarn workspaces run clean",
6364
"clean:parallel": "concurrently 'yarn workspace @spectrum-charts/themes clean' 'yarn workspace @spectrum-charts/constants clean' 'yarn workspace @spectrum-charts/utils clean' 'yarn workspace @spectrum-charts/locales clean' 'yarn workspace @spectrum-charts/vega-spec-builder clean' 'yarn workspace @adobe/react-spectrum-charts clean'",
6465
"build:force": "yarn clean && yarn build",
@@ -73,6 +74,7 @@
7374
"sonar": "node ./scripts/runSonarOnBranch.js",
7475
"sonar-fork-pr": "node ./scripts/runSonarOnFork.js",
7576
"start": "yarn storybook",
77+
"start:docs": "yarn workspace @spectrum-charts/docs start",
7678
"storybook": "cross-env NODE_OPTIONS=--openssl-legacy-provider && storybook dev -p 6009",
7779
"test": "cross-env TZ=UTC BABEL_ENV=test jest",
7880
"watch": "cross-env TZ=UTC BABEL_ENV=test jest --watch",

packages/docs/.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react"
5+
]
6+
}

packages/docs/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# React Spectrum Charts Documentation
2+
3+
This package contains the documentation website for React Spectrum Charts, built with [Docusaurus](https://docusaurus.io/).
4+
5+
## Development
6+
7+
To start the development server:
8+
9+
```bash
10+
# From the root of the monorepo
11+
yarn workspace @spectrum-charts/docs start
12+
```
13+
14+
This will start a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
15+
16+
## Build
17+
18+
To build the documentation:
19+
20+
```bash
21+
# From the root of the monorepo
22+
yarn workspace @spectrum-charts/docs build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
## Writing Documentation
28+
29+
The documentation is written in Markdown and is located in the `docs` directory. The sidebar structure is defined in `sidebars.ts`.
30+
31+
### Directory Structure
32+
33+
```
34+
docs/
35+
├── docs/
36+
│ ├── intro.md
37+
│ ├── installation.md
38+
│ ├── Developer-Docs.md
39+
│ ├── guides/
40+
│ ├── api/
41+
│ └── supplemental/
42+
├── src/
43+
│ ├── components/
44+
│ ├── css/
45+
│ ├── pages/
46+
│ └── theme/
47+
└── static/
48+
└── img/
49+
```
50+
51+
## Contributing
52+
53+
Please see the main repository's CONTRIBUTING.md file for guidelines on how to contribute to the documentation.

0 commit comments

Comments
 (0)