Skip to content

Commit 58bc0e6

Browse files
Copilotabraham
andcommitted
Fix regex to handle attributes without Version history section
Co-authored-by: abraham <[email protected]>
1 parent 0cabc43 commit 58bc0e6

File tree

4 files changed

+62
-15
lines changed

4 files changed

+62
-15
lines changed

dist/schema.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34723,12 +34723,23 @@
3472334723
"type": "object",
3472434724
"description": "Represents the last read position within a user's timelines.",
3472534725
"properties": {
34726+
"last_read_id": {
34727+
"description": "The ID of the most recently viewed entity.",
34728+
"type": "string"
34729+
},
34730+
"updated_at": {
34731+
"description": "The timestamp of when the marker was set.",
34732+
"type": "string",
34733+
"format": "date-time"
34734+
},
3472634735
"version": {
3472734736
"description": "An incrementing counter, used for locking to prevent write conflicts.",
3472834737
"type": "integer"
3472934738
}
3473034739
},
3473134740
"required": [
34741+
"last_read_id",
34742+
"updated_at",
3473234743
"version"
3473334744
],
3473434745
"externalDocs": {
@@ -34791,6 +34802,20 @@
3479134802
"type": [
3479234803
"object",
3479334804
"null"
34805+
],
34806+
"properties": {
34807+
"x": {
34808+
"description": "Horizontal focal point",
34809+
"type": "number"
34810+
},
34811+
"y": {
34812+
"description": "Vertical focal point",
34813+
"type": "number"
34814+
}
34815+
},
34816+
"required": [
34817+
"x",
34818+
"y"
3479434819
]
3479534820
}
3479634821
}

src/__tests__/integration/application-redirect-uri-description.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@ describe('Integration test - Application redirect_uri description', () => {
55
const entityParser = new EntityParser();
66
const entities = entityParser.parseAllEntities();
77

8-
const applicationEntity = entities.find(entity => entity.name === 'Application');
8+
const applicationEntity = entities.find(
9+
(entity) => entity.name === 'Application'
10+
);
911
expect(applicationEntity).toBeDefined();
1012

11-
const redirectUriAttr = applicationEntity?.attributes.find(attr => attr.name === 'redirect_uri');
13+
const redirectUriAttr = applicationEntity?.attributes.find(
14+
(attr) => attr.name === 'redirect_uri'
15+
);
1216
expect(redirectUriAttr).toBeDefined();
1317

1418
// Verify the full description is captured including the newline reference
1519
expect(redirectUriAttr?.description).toContain('May contain');
1620
expect(redirectUriAttr?.description).toContain('\\n');
17-
expect(redirectUriAttr?.description).toContain('characters when multiple redirect URIs are registered');
18-
21+
expect(redirectUriAttr?.description).toContain(
22+
'characters when multiple redirect URIs are registered'
23+
);
24+
1925
// Check that it doesn't contain any version history content
2026
expect(redirectUriAttr?.description).not.toContain('4.3.0');
2127
expect(redirectUriAttr?.description).not.toContain('deprecated in favour');
2228
});
23-
});
29+
});

src/__tests__/parsers/AttributeParser.newline-description.test.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ describe('AttributeParser - Newline in description', () => {
1919
expect(attributes[0].name).toBe('redirect_uri');
2020
expect(attributes[0].description).toContain('May contain');
2121
expect(attributes[0].description).toContain('\\n');
22-
expect(attributes[0].description).toContain('characters when multiple redirect URIs are registered');
22+
expect(attributes[0].description).toContain(
23+
'characters when multiple redirect URIs are registered'
24+
);
2325
expect(attributes[0].deprecated).toBe(true);
2426
});
2527

@@ -39,9 +41,15 @@ completely until the Type section.\\
3941

4042
expect(attributes).toHaveLength(1);
4143
expect(attributes[0].name).toBe('multiline_field');
42-
expect(attributes[0].description).toContain('This is a description that spans');
43-
expect(attributes[0].description).toContain('multiple lines and should be captured');
44-
expect(attributes[0].description).toContain('completely until the Type section');
44+
expect(attributes[0].description).toContain(
45+
'This is a description that spans'
46+
);
47+
expect(attributes[0].description).toContain(
48+
'multiple lines and should be captured'
49+
);
50+
expect(attributes[0].description).toContain(
51+
'completely until the Type section'
52+
);
4553
});
4654
});
4755

@@ -63,7 +71,9 @@ completely until the Type section.\\
6371
expect(attributes[0].name).toBe('redirect_uri');
6472
expect(attributes[0].description).toContain('May contain');
6573
expect(attributes[0].description).toContain('\\n');
66-
expect(attributes[0].description).toContain('characters when multiple redirect URIs are registered');
74+
expect(attributes[0].description).toContain(
75+
'characters when multiple redirect URIs are registered'
76+
);
6777
expect(attributes[0].deprecated).toBe(true);
6878
});
6979

@@ -83,9 +93,15 @@ completely until the Type section.\\
8393

8494
expect(attributes).toHaveLength(1);
8595
expect(attributes[0].name).toBe('multiline_field');
86-
expect(attributes[0].description).toContain('This is a description that spans');
87-
expect(attributes[0].description).toContain('multiple lines and should be captured');
88-
expect(attributes[0].description).toContain('completely until the Type section');
96+
expect(attributes[0].description).toContain(
97+
'This is a description that spans'
98+
);
99+
expect(attributes[0].description).toContain(
100+
'multiple lines and should be captured'
101+
);
102+
expect(attributes[0].description).toContain(
103+
'completely until the Type section'
104+
);
89105
});
90106
});
91-
});
107+
});

src/parsers/AttributeParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class AttributeParser {
6060
/\*\*Description:\*\*\s*(.*?)\\?\s*\n\*\*Type:\*\*/s
6161
);
6262
const typeMatch = sectionContent.match(
63-
/\*\*Type:\*\*\s*(.*?)(?=\n.*?(?:`[^`]+`\s*=|\*\*Version history:\*\*))/s
63+
/\*\*Type:\*\*\s*(.*?)(?=\n(?:\*\*Version history:\*\*|###|####|`[^`]+`\s*=|\d+\.\d+\.\d+\s*-|$))/s
6464
);
6565

6666
// Look for Version history in this specific section

0 commit comments

Comments
 (0)