Skip to content

Commit 041ec80

Browse files
authored
check style (#173)
* add instructions for local instance * generate prompt * refactored for reuse and graceful failure * send to LLM * extract revision from element * specify additional styles * directory name * terminology * refactored * get diff between original and revision * terminology violations * US English * refactor * improve diff * option to skip LLM for testing * get the title back * parse response and diff into comments * parse response and diff into comments * fix line calculation * fix line calculation * post overall comment
1 parent a9bc3c9 commit 041ec80

11 files changed

+413
-53
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ fern/dist
33
fern/*/definition/
44
.DS_Store
55
.idea
6-
temp
6+
temp
7+
__pycache__

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
# DevRev Docs
22

3-
Tagging a release on this repository will update the following clients:
3+
Merging a change in this repository will update the following clients:
44

5-
- [API Docs](https://devrev.docs.buildwithfern.com)
6-
7-
## What is in this repository?
5+
- [API Docs](https://developer.devrev.ai)
86

97
This repository contains
108

119
- DevRev's `Public` OpenAPI spec & `Beta` OpenAPI spec
1210
- Fern configuration
1311

14-
## What is in the API Definition?
12+
## API definition
1513

16-
The API Definition contains an OpenAPI specification adapted to be compatible with Fern.
14+
The API Definition contains an OpenAPI specification adapted to be compatible with Fern. The specs are in `/fern/apis`.
1715

1816
To make sure that the definition is valid, you can use the Fern CLI.
1917

@@ -22,9 +20,9 @@ npm install -g fern-api # Installs CLI
2220
fern check # Checks if the definition is valid
2321
```
2422

25-
## What are generators?
23+
## Generators
2624

27-
Generators read in your API Definition and output artifacts (e.g. the TypeScript SDK Generator) and are tracked in [generators.yml](./fern/api/generators.yml).
25+
Generators read in your API Definition and output artifacts (the TypeScript SDK Generator) and are tracked in [generators.yml](./fern/api/generators.yml).
2826

2927
To trigger the generators run:
3028

@@ -33,15 +31,14 @@ To trigger the generators run:
3331
fern generate --version <version>
3432
```
3533

36-
## Upgrading Fern
37-
You can use the following command to upgrade fern to the latest version:
38-
```bash
39-
fern upgrade --rc
34+
## Run a local instance
35+
36+
In the root of this repository:
37+
```
38+
cd custom-implementation/ && npm i && npm run build && cd ..
39+
fern docs dev
4040
```
4141

4242
### Troubleshooting
4343

4444
If you run into errors, you can add the ` --log-level debug` flag to get more information.
45-
46-
If you get a 403 error, you may need to first run `fern login`. You might also need to be added
47-
to the Vellum org in Fern, which requires contacting the fern team in #fern-x-vellum in Slack.

changelog.py

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import yaml
22
import argparse
3-
import requests
4-
import os
53
import datetime
6-
import re
4+
import llm_client
75

86

97
def main(vrn, d):
@@ -17,43 +15,16 @@ def main(vrn, d):
1715
outfile.write(p)
1816
print(f"Wrote prompt to {pr_file}.")
1917

20-
l = gen_log(p)
18+
l = llm_client.get_response(p)
2119

2220
log_file = f"./fern/apis/{vrn}/changelog/{d}.md"
23-
with open(log_file, 'w', encoding="utf-8") as outfile:
24-
outfile.write(l)
25-
print(f"Wrote log to {log_file}.")
26-
27-
28-
def gen_log(prompt):
29-
30-
auth = os.environ.get('LLM_JWT')
31-
if auth:
32-
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {auth}"}
33-
payload = {
34-
"model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
35-
"messages": [
36-
{
37-
"role": "user",
38-
"content": prompt
39-
}
40-
]
41-
}
42-
43-
try:
44-
r = requests.post('https://openwebui.dev.devrev-eng.ai/api/chat/completions', json=payload,
45-
headers=headers)
46-
log = r.json()['choices'][0]['message']['content']
47-
log = re.sub(r"^# .*\n?", '', log, flags=re.MULTILINE)
48-
log = re.sub(r"^Here.*\n?", '', log, flags=re.MULTILINE)
49-
log = re.sub(r"^Let me know.*\n?", '', log, flags=re.MULTILINE)
50-
except Exception as e:
51-
print(
52-
f"Failed to generate changelog. Error: {type(e)} {e} {r}")
21+
if (l):
22+
with open(log_file, 'w', encoding="utf-8") as outfile:
23+
outfile.write(l)
24+
print(f"Wrote log to {log_file}.")
5325
else:
54-
log = "No auth token"
55-
56-
return log
26+
print(f"Failed to generate {log_file}.")
27+
5728

5829

5930
def gen_prompt(oasdiff, links, version):

llm_client.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
import re
3+
import requests
4+
5+
def get_response(prompt):
6+
7+
auth = os.environ.get('LLM_JWT')
8+
if auth:
9+
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {auth}"}
10+
payload = {
11+
"model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
12+
"messages": [
13+
{
14+
"role": "user",
15+
"content": prompt
16+
}
17+
]
18+
}
19+
20+
try:
21+
r = requests.post('https://openwebui.dev.devrev-eng.ai/api/chat/completions', json=payload,
22+
headers=headers)
23+
response = r.json()['choices'][0]['message']['content']
24+
response = re.sub(r"^# .*\n?", '', response, flags=re.MULTILINE)
25+
response = re.sub(r"^Here.*\n?", '', response, flags=re.MULTILINE)
26+
response = re.sub(r"^Let me know.*\n?", '', response, flags=re.MULTILINE)
27+
return response
28+
except Exception as e:
29+
print(f"Failed to generate changelog. Error: {type(e)} {e} {r}")
30+
return None
31+
32+
def get_lines_between_tags(text, tag):
33+
pattern = r'<' + tag + r'>(.*?)<\/' + tag + r'>'
34+
matches = re.findall(pattern, text, re.DOTALL)
35+
return "".join([match.strip() for match in matches])
36+
37+
def get_lines_before_tag(text, tag):
38+
pattern = r'(.*?)<' + tag + r'>'
39+
matches = re.findall(pattern, text, re.DOTALL)
40+
return "".join([match.strip() for match in matches])

style/prompt.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
You are an expert technical documentation editor. Analyze the included document and revise it so that it adheres to the following style rules. While you can make suggestions for being more concise, be very careful not to remove any facts from the document. Also do not change the document structure, including removing the title or headings, unless the original structure violates any of the guidelines. Also check the terminology given in CSV format inside the `<terminology>` element.
2+
3+
In your response, summarize the violations that you fixed. Return the revised markdown inside a separate element `<document>` element, just like in this request, that contains only the document and no other commentary. I’m going to read your suggestions through an API and need to be able to get just the document for the next stage.

style/sample-common.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# DataDog Snap-in
2+
3+
This integration links Datadog's monitoring system with Devrev's incident management, simplifying the process of managing RevOrg incidents triggered by Datadog alerts. It automatically generates new incidents and updates existing incidents in DevRev using data from Datadog, allowing your organisation to address issues efficiently without manual tracking.
4+
5+
### System Features
6+
7+
- Automated Incident Creation: When an incident is triggered in Datadog, the snap-in automatically creates a corresponding incident in DevRev.
8+
- Automated Incident Updation: When an incident is updated in Datadog, the changes are reflected in DevRev.
9+
- Real-Time Synchronization: The snap-in ensures that incidents are created or updated in real-time, reducing delays between detection and resolution. DevRev captures the necessary incident details from the Datadog payload, allowing teams to address and mitigate issues.
10+
- Seamless integration: The snap-in is built to streamline workflows, minimizing the need for manual intervention.
11+
12+
### Installing the Snap-in
13+
14+
1. Open the DevRev marketplace and install the **Datadog** snap-in.
15+
2. Select the dev org where you want to install the snap-in, confirm your
16+
selection, and click **Deploy snap-in**.
17+
3. In DevRev app, setup the connection in **Settings** > **Snap-ins** >
18+
**Connections** on top.
19+
- Search and choose an existing connection or create a new one by clicking
20+
**+ Connection**.
21+
- Select **Datadog** from the dropdown list.
22+
- Give it a connection name and paste your Datadog **API Key**, **Application
23+
Key** and **Environment**(prod/dev) in their respective fields.
24+
25+
### Configuration
26+
27+
1. Navigate to **Snap-ins** > **All Snap-ins** > **Datadog** > **Configure**.
28+
2. Select the connection that you created in the **Connections** tab.
29+
30+
This connection is necessary if you wish to bring stage and custom fields to DevRev.
31+
32+
3. The default owner, part, and default severity value for incidents must be included.
33+
4. Include the desired stage mapping from Datadog to DevRev.
34+
5. Click **Save**
35+
6. Click **Install**.
36+
7. Copy the webhook URL and follow the below steps to connect it to Datadog via webhook integration.
37+
1. Add the following payload in the **Payload** section.
38+
- `"aggreg_key": "$AGGREG_KEY"`.
39+
- `"alert_metric": "$ALERT_METRIC"`.
40+
- `"alert_query": "$ALERT_QUERY"`.
41+
2. Click **Install Integration** or **Update Configuration**.
42+
43+
### References
44+
45+
- [DataDog Devrev snap-in marketplace listing](https://marketplace.devrev.ai/datadog-snapin)
46+
- [DataDog DevRev snapin documentation](https://devrev.ai/docs/integrations/datadog)
47+
- [DataDog API](https://docs.datadoghq.com/api/latest/)

style/sample-developer.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Developer sample
2+
3+
## Initialize
4+
5+
Place the following code in the `<body>` section of your HTML page.
6+
7+
```html
8+
<script>
9+
window.plugSDK.init({
10+
// Please ensure you replace the app_id with your unique app id
11+
app_id: "<your_unique_app_id>",
12+
});
13+
</script>
14+
```
15+
```jsx
16+
<script
17+
type="text/javascript"
18+
src="https://plug-platform.devrev.ai/static/plug.js"
19+
></script>;
20+
```
21+
```jsx
22+
useEffect(() => {
23+
window.plugSDK.init({
24+
// Please ensure you replace the app_id with your unique app id
25+
app_id: "<your_unique_app_id>",
26+
});
27+
}, []);
28+
```
29+
30+
## Tracking user events
31+
32+
To track user events through PLuG, employ the `trackEvent` method provided by the PLuG SDK.
33+
34+
**trackEvent**
35+
36+
```
37+
window.plugSDK.trackEvent(event_name, properties)
38+
39+
```

style/style-common.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Rules
2+
3+
For the writing style, apply the following descriptive keywords to analyzing the draft document:
4+
5+
- Writing style: authoritative, comprehensive, helpful
6+
- Sentence structure: varied, complex, cohesive
7+
- Vocabulary choice: consistent, technical
8+
- Grammar and syntax: structured, flawless, articulate
9+
- Descriptive language: clear, concise, informative
10+
- Language variant: standard technical/professional US American English; not British, Indian, or other variants.
11+
12+
There are also some very specific style rules that need to be followed:
13+
14+
- Use sentence case (only capitalize the first word and proper nouns) in any type of heading, including in two-level lists.
15+
- Ensure that any list is in parallel structure (use the same syntax for every entry).
16+
- Instructions or how-to guides:
17+
- They may use two levels; both should be ordered (numbered) lists, not unordered (bulleted).
18+
- Instructions should be in imperative mood.
19+
- If there is a location or condition in a step, it should be at the front of the sentence, which must still be in imperative.
20+
- Steps should be more than a single “click”; combine steps if needed to make them more meaningful.
21+
- End each list item with a period or other appropriate sentence-ending punctuation, except in the following cases:
22+
- If the item consists of a single word, don't add end punctuation.
23+
- If the item doesn't include a verb, don't add end punctuation.
24+
- If the item is entirely in code font, don't add end punctuation.
25+
- If the item is entirely link text or a document title, don't add end punctuation.
26+
- Titles of instructions or how-to guides should be a verb in the infinitive form without “to”, not a gerund (ending in -ing). Titles of any other type of section should be noun phrases.

style/style-developer.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Developer-specific style
2+
3+
- Don't change text inside inline code phrases or code blocks.
4+
- Always specify a language for codeblocks.
5+
- Wrap adjacent codeblocks in a `<CodeBlocks>` element.
6+
- If a codeblock is preceded by a title, move the title to the codeblock.
7+
Example before:
8+
```
9+
**Request**
10+
```bash
11+
curl -X POST -H "Content-Type: application/json"
12+
```
13+
Example after:
14+
```
15+
```bash Request
16+
curl -X POST -H "Content-Type: application/json"
17+
```
18+
```

style/term-common.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deprecated;Approved
2+
foo;example
3+
Devrev;DevRev
4+
RevOrg;workspace
5+
RevUser;customer
6+
snapin;snap-in

0 commit comments

Comments
 (0)