Skip to content

Commit fd26fd1

Browse files
New OP guide styles (#100)
1 parent ee56569 commit fd26fd1

File tree

1 file changed

+124
-1
lines changed

1 file changed

+124
-1
lines changed

src/content/docs/content/openpayments.mdx

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ import { Card, Steps } from '@astrojs/starlight/components';
1818
</Card>
1919

2020
<Card title="After a Starlight upgrade to open-payments" icon="star">
21+
2122
```
2223
cd <to project folder>
2324
pnpm install
2425
cd docs
2526
pnpm start
2627
```
28+
2729
</Card>
2830

2931
## Nouns
@@ -45,4 +47,125 @@ pnpm start
4547

4648
### Open Payments
4749

48-
Spell as two words, not one (OpenPayments).
50+
Spell as two words, not one (OpenPayments).
51+
52+
## Concept docs
53+
54+
All concepts docs (and the getting started overview) should have a summary at the top that gives a TL;DR of the contents/purpose of the page.
55+
56+
For now, we're using the `:::tip` aside with the default rocket icon. In newer versions of Starlight, you can use custom icons. We'll replace the rocket when our version is updated.
57+
58+
https://starlight.astro.build/components/asides/#use-custom-icons
59+
60+
## Developer guides
61+
62+
The following sections, at minimum, should be included in all Open Payments developer guides. Included below are some highish-level style standards, but you should look to existing guides for the bigger picture.
63+
64+
### Summary
65+
66+
Use the `:::tip` aside and briefly describe the purpose of the guide. Don't repeat the page title.
67+
68+
### Overview
69+
70+
Include some general information about the guide that helps to set up the subsequent Scenario section.
71+
72+
For example, in *Set up recurring payments with a fixed incoming amount*, we use a "subscription payment" as a general example of a recurring transfer of money of the same amount. Then, the scenario section uses "streaming service" as a specific kind of recurring subscription.
73+
74+
### Scenario
75+
76+
Describe the specific scenario the guide will cover. Include values for things like currency type, amount, recurrence schedule, etc. The guide's steps must follow what you describe here.
77+
78+
List and define the parties involved in the scenario. One will always be the reader of the guide and the role they're assuming (developer, platform operator, etc.). Other parties could include merchant/retailer, service provider, customer, sender, recipient.
79+
80+
Bold the party name and use a (bold) colon. Then include the description in normal text. For example:
81+
82+
* **Retailer:** the athletics company
83+
* **Developer:** you, as the developer working on the client appropriate
84+
85+
:::note
86+
This was a style that naturally came about, not one that was discussed. If you find guides that don't follow this format, update them. Not a high priority.
87+
:::
88+
89+
Remember to refer to existing guides for examples.
90+
91+
### Endpoints
92+
93+
Provide a bulleted list of every API that's used in the guide. Prefix each API with the appropriate Badge and wrap each API name in the LinkOut component.
94+
95+
```
96+
<Badge text="GET" variant="note" />
97+
```
98+
```
99+
<Badge text="POST" variant="success" />
100+
```
101+
```
102+
<Badge text="DELETE" variant="danger" />
103+
```
104+
105+
If the guide mentions optional APIs, exclude them from this list. This list is what's *required*.
106+
107+
### Steps
108+
109+
* [The steps themselves](#the-steps-themselves)
110+
* [Step overview](#step-overview)
111+
* [Code for requests](#code-for-requests)
112+
* [Code for responses](#code-for-responses)
113+
114+
#### The steps themselves
115+
116+
* Each step number is a heading (usually an H3).
117+
* Each step starts with a verb (no -ing suffix).
118+
* Use existing guides as a template for how to word the steps. For example, *Request the creation of an incoming payment resource* is wordy, but it clearly indicates we're talking about a resource, not a grant.
119+
120+
#### Step overview
121+
122+
* Each step should have some kind of explanation about its purpose.
123+
* If you're instructing someone to call an API, prefix the API name with the appropriate Badge component (see [Endpoints](#endpoints)) and relative-link the name of the API to its page. If you're only mentioning an API, exclude a Badge or link.
124+
125+
#### Code for requests
126+
127+
Request snippets should come from a developer. If the developer is nice enough to add the snippets to the doc, review the markdown to make sure it's formatted correctly.
128+
129+
* Each step should use a synced Tabs component (`<Tabs syncKey="lang">`).
130+
* Each language should have its own tab and include the lang's icon, if available.
131+
* Each code block should specify the lang and use the `wrap` property (` ```ts wrap `).
132+
133+
Update each snippet, when possible, to be specific to your scenario. Look at other guides for examples. You might need a developer to help with parts of it.
134+
135+
If you think a parameter or value needs additional explanation, use a double backslash and add a comment to the end of the line (`// the management uri`).
136+
137+
:::note
138+
Don't add blank lines between code in a block. It causes errors.
139+
:::
140+
141+
#### Code for responses
142+
143+
We should be able to create the API responses by using the snippets and our API docs.
144+
145+
When formatting the response:
146+
* Hide the response in a `<detail>` element.
147+
* Use `Example response` (or similar) as the `summary`.
148+
* Include a descriptive sentence or two about where the response is coming from.
149+
* Use ` ```json wrap ` in the code block.
150+
151+
:::note
152+
Don't add blank lines between code in a block. It causes errors.
153+
:::
154+
155+
When revising the response's values:
156+
* Make sure they're specific to your scenario.
157+
* Pay attention to timestamp values (e.g., `createdAt`). They should incrementally increase as the steps progress.
158+
* Fully or partially abbreviate long values that aren't needed to understand the flow. We commonly use this for access tokens, UUIDs, ilp addresses, and shared secrets. Add an inline comment to the end of the line describing what the value represents.
159+
* If abbreviating the whole value, use `"..."`.
160+
```json wrap title="Example"
161+
{
162+
"access_token": {
163+
"value": "...", //access token value for incoming payment grant
164+
}
165+
}
166+
* If abbreviating part of a value, use `{...}`.
167+
```json wrap title="Example"
168+
{
169+
"manage": "https://auth.happylifebank.example.com/token/{...}", // management uri for access token
170+
}
171+
```

0 commit comments

Comments
 (0)