Skip to content

Commit fe40b79

Browse files
Update contribution guidelines (#1541)
1 parent 918391c commit fe40b79

File tree

1 file changed

+127
-41
lines changed

1 file changed

+127
-41
lines changed

CONTRIBUTING.md

Lines changed: 127 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ guide in some places.
1111
- [Preview locally](#preview-locally)
1212
- [Style guide](#style-guide)
1313
- [Add images](#add-images)
14-
- [Format Markdown and MDX](#format-markdown-and-mdx)
15-
- [Live code blocks](#live-code-blocks)
14+
- [Update the interactive API reference](#update-the-interactive-api-reference)
15+
- [Update `MetaMask/api-specs`](#update-metamaskapi-specs)
16+
- [Update `ethereum/execution-apis`](#update-ethereumexecution-apis)
17+
- [Test analytics](#test-analytics)
1618

1719
## Contribution workflow
1820

@@ -35,7 +37,7 @@ To contribute changes:
3537
this repository to your computer and navigate into it.
3638

3739
```bash
38-
git clone https://github.com/MetaMask/metamask-docs.git
40+
git clone git@github.com:MetaMask/metamask-docs.git
3941
cd metamask-docs
4042
```
4143

@@ -46,9 +48,9 @@ To contribute changes:
4648
> to be able to pull from and push to the original repository.
4749
>
4850
> ```bash
49-
> git clone https://github.com/<YOUR-USERNAME>/metamask-docs.git
51+
> git clone git@github.com:<YOUR-USERNAME>/metamask-docs.git
5052
> cd metamask-docs
51-
> git remote add upstream https://github.com/MetaMask/metamask-docs.git
53+
> git remote add upstream git@github.com:MetaMask/metamask-docs.git
5254
> ```
5355
5456
3. [Create and checkout a topic branch](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging),
@@ -69,12 +71,16 @@ To contribute changes:
6971

7072
> **Notes:**
7173
>
72-
> - All documentation content is located in the `wallet` and `snaps` directories.
73-
> - If you add a new documentation page, make sure to edit `wallet-sidebar.js` or
74-
> `snaps-sidebar.js` to add the page to the
74+
> - All documentation content is located in the `wallet`, `snaps`, `services`, and
75+
> `developer-tools` directories.
76+
> - If you add a new documentation page, edit `wallet-sidebar.js`, `snaps-sidebar.js`,
77+
> `services-sidebar.js`, or `dashboard-sidebar.js` to add the page to the
7578
> [sidebar](https://docs-template.consensys.net/contribute/configure-docusaurus#sidebar).
76-
> - If you delete, rename, or move a documentation file, make sure to add a
77-
> [redirect](https://docs-template.consensys.net/contribute/configure-docusaurus#redirects).
79+
> - If you delete, rename, or move a documentation file, add a
80+
> [redirect](https://vercel.com/docs/edge-network/redirects#configuration-redirects).
81+
> - See additional instructions for [updating the interactive API reference](#update-the-interactive-api-reference).
82+
> - If the PR contains a major change to the documentation content, add an entry to the top of
83+
> the ["What's new?"](docs/whats-new.md) page.
7884
7985
5. [Preview your changes locally](https://docs-template.consensys.net/contribute/preview) to check
8086
that the changes render correctly.
@@ -114,49 +120,129 @@ Refer to the [Consensys documentation style guide](https://docs-template.consens
114120

115121
## Add images
116122

117-
All images are located in the `wallet/assets` and `snaps/assets` directories.
123+
All images are located in the `wallet/assets`, `snaps/assets`, `services/images`, and
124+
`developer-tools/images` directories.
118125
When adding a new image, such as a screenshot or diagram, make sure the image has a white or
119126
`#1b1b1d` color background in order for it to be compatible with the site's light and dark modes.
120127

121128
Additionally, follow the [Consensys guidelines on adding images](https://docs-template.consensys.net/contribute/add-images).
122129

123-
## Format Markdown and MDX
130+
## Update the interactive API reference
124131

125-
The documentation is built using [Docusaurus](https://docusaurus.io/), which is powered by
126-
[MDX](https://mdxjs.com/), an extension to [Markdown](https://www.markdownguide.org/) that allows
127-
you to use [React JSX](https://www.w3schools.com/react/react_jsx.asp) in your Markdown content.
132+
The [Wallet JSON-RPC API reference](https://docs.metamask.io/wallet/reference/json-rpc-api/) uses the
133+
[`docusaurus-openrpc`](https://github.com/MetaMask/docusaurus-openrpc) plugin to import OpenRPC
134+
specifications from [`MetaMask/api-specs`](https://github.com/MetaMask/api-specs) (MetaMask-specific
135+
methods) and [`ethereum/execution-apis`](https://github.com/ethereum/execution-apis) (standard
136+
Ethereum methods).
137+
The site renders documentation for each method based on the specification, and displays an
138+
interactive module to test the methods in your browser.
128139

129-
Follow the [Consensys guidelines on formatting Markdown](https://docs-template.consensys.net/contribute/format-markdown).
130-
The MetaMask docs also use a plugin to implement [live code blocks](#live-code-blocks).
140+
### Update `MetaMask/api-specs`
131141

132-
### Live code blocks
142+
To update documentation for MetaMask-specific JSON-RPC API methods:
133143

134-
The [`remark-codesandbox`](https://github.com/kevin940726/remark-codesandbox/) plugin allows you to
135-
define a code block to be loaded live in a CodeSandbox iframe.
136-
This enhances the documentation by keeping the code blocks versioned and in the codebase, while
137-
using CodeSandbox to showcase any example with any dependency.
144+
1. Fork [`MetaMask/api-specs`](https://github.com/MetaMask/api-specs), clone the forked repository
145+
to your computer, and navigate into it:
138146

139-
Define a live code block by adding a `codesandbox` key to the code block.
140-
For example:
141-
142-
````jsx
143-
```javascript codesandbox=vanilla
144-
// JavaScript live code block
145-
```
146-
````
147-
148-
`remark-codesandbox` allows for simple code blocks where the content of the block replaces the
149-
CodeSandbox entry point, and more complex code blocks that can be loaded directly from the
150-
filesystem.
151-
See the
152-
[`remark-codesandbox` documentation](https://github.com/kevin940726/remark-codesandbox/#documentation)
153-
for more information.
154-
155-
## Analytics
147+
```bash
148+
git clone git@github.com:<YOUR-USERNAME>/api-specs.git
149+
cd api-specs
150+
```
151+
152+
2. Follow the repository's [`README.md`](https://github.com/MetaMask/api-specs/blob/main/README.md)
153+
instructions to edit the OpenRPC specification and generate the output file, `openrpc.json`.
154+
155+
3. To test the API updates in the MetaMask doc site's interactive reference, make the following
156+
temporary changes on a local branch of the doc site, `metamask-docs`:
157+
158+
1. Copy and paste the output file `openrpc.json` into the root directory of `metamask-docs`.
159+
2. In `docusaurus.config.js`, update the following line to point to your local output file:
160+
```diff
161+
openrpcDocument:
162+
- "https://metamask.github.io/api-specs/0.10.5/openrpc.json",
163+
+ "./openrpc.json",
164+
```
165+
3. Preview the doc site locally, navigate to the API reference, and view your updates.
166+
167+
4. Add and commit your changes to `api-specs`, and create a PR.
168+
169+
5. Once your PR is approved and merged, the following must happen to publish the changes to the
170+
MetaMask doc site:
171+
172+
1. A new version of `api-specs` must be released by a user with write access to the repository.
173+
To release, go to the [Create Release Pull Request](https://github.com/MetaMask/api-specs/actions/workflows/create-release-pr.yml)
174+
action, select **Run workflow**, and enter a specific version to bump to in the last text box
175+
(for example, `0.10.6`). This creates a PR releasing a version of `api-specs`.
176+
2. Once the release PR is merged, the [Publish Release](https://github.com/MetaMask/api-specs/actions/workflows/publish-release.yml)
177+
action must be approved by an npm publisher.
178+
You can request an approval in the **#metamask-dev** Slack channel tagging
179+
**@metamask-npm-publishers**.
180+
For example:
181+
> @metamask-npm-publishers `@metamask/api-specs@0.10.6` is awaiting deployment :rocketship:
182+
https://github.com/MetaMask/api-specs/actions/runs/10615788573
183+
3. Once the release is published on npm, `docusaurus.config.js` in `metamask-docs` must be
184+
updated with the new `api-specs` version to publish.
185+
For example:
186+
```diff
187+
openrpcDocument:
188+
- "https://metamask.github.io/api-specs/0.10.5/openrpc.json",
189+
+ "https://metamask.github.io/api-specs/0.10.6/openrpc.json",
190+
```
191+
192+
### Update `ethereum/execution-apis`
193+
194+
To update documentation for standard Ethereum JSON-RPC API methods:
195+
196+
1. Fork [`ethereum/execution-apis`](https://github.com/ethereum/execution-apis), clone the forked
197+
repository to your computer, and navigate into it:
156198

157-
The [`docusaurus-plugin-segment`](https://github.com/xer0x/docusaurus-plugin-segment) plugin enables simple usage analytics to inform documentation improvements that may be needed.
199+
```bash
200+
git clone git@github.com:<YOUR-USERNAME>/execution-apis.git
201+
cd execution-apis
202+
```
158203

159-
If you need to test analytics events in your local development environment be sure to export the appropriate key for the environment you are testing against before building and running the project:
204+
2. Follow the repository's [`README.md`](https://github.com/ethereum/execution-apis/blob/main/README.md)
205+
instructions to edit the OpenRPC specification and generate the output file, `openrpc.json`.
206+
207+
3. To test the API updates in the MetaMask doc site's interactive reference, make the following
208+
temporary changes on a local branch of the doc site, `metamask-docs`:
209+
210+
1. Copy and paste the output file `openrpc.json` into the root directory of `metamask-docs`.
211+
2. In `docusaurus.config.js`, update the following line to point to your local output file:
212+
```diff
213+
openrpcDocument:
214+
- "https://metamask.github.io/api-specs/0.10.5/openrpc.json",
215+
+ "./openrpc.json",
216+
```
217+
3. Preview the doc site locally, navigate to the API reference, and view your updates.
218+
219+
4. Add and commit your changes to `execution-apis`, and create a PR.
220+
221+
5. Once your PR is approved and merged, the following must happen to publish the changes to the
222+
MetaMask doc site:
223+
224+
1. `api-specs` must import the updated Ethereum API specification.
225+
Go to the [commit history](https://github.com/ethereum/execution-apis/commits/assembled-spec/)
226+
of the `assembled-spec` branch of `execution-apis`.
227+
Copy the full commit hash of the latest commit titled "assemble openrpc.json."
228+
Update the following line in `merge-openrpc.js` of `api-specs` with the updated commit hash,
229+
and create a PR:
230+
```diff
231+
const getFilteredExecutionAPIs = () => {
232+
- return fetch("https://raw.githubusercontent.com/ethereum/execution-apis/ac19b518a2596221cd7cd6421ee3dc654d7ff3b7/refs-openrpc.json")
233+
+ return fetch("https://raw.githubusercontent.com/ethereum/execution-apis/f75d4cc8eeb5d1952bd69f901954686b74c34c9b/refs-openrpc.json")
234+
```
235+
2. Once the change to `merge-openrpc.js` is merged, Step 5 in
236+
[Update `MetaMask/api-specs`](#update-metamaskapi-specs) must be completed to publish the
237+
changes to the MetaMask doc site.
238+
239+
## Test analytics
240+
241+
The [`docusaurus-plugin-segment`](https://github.com/xer0x/docusaurus-plugin-segment) plugin enables
242+
simple usage analytics to inform documentation improvements.
243+
244+
If you need to test analytics events in your local development environment, export the appropriate
245+
key for the environment you are testing against before building and running the project:
160246

161247
```bash
162248
export SEGMENT_ANALYTICS_KEY="<your key>"

0 commit comments

Comments
 (0)