Skip to content

Commit 1ec8d16

Browse files
authored
Merge pull request #499 from abraham/specials
Apply overrides from git commits
2 parents e04939d + 8ab2e2a commit 1ec8d16

File tree

5 files changed

+139
-6
lines changed

5 files changed

+139
-6
lines changed

config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
"mastodonDocsCommit": "f760ffcdf3371a641ba5d731dd33348fc6eb4fe6",
33
"mastodonVersion": "4.4.0",
44
"minimumMastodonVersion": "4.2.0",
5-
"blockedFiles": ["methods/notifications_alpha.md"]
5+
"blockedFiles": ["methods/notifications_alpha.md"],
6+
"overridesRepository": "https://github.com/abraham/documentation",
7+
"overrideCommits": ["b1d8f95b506e2d734876ef47ec0f4e1feb4f5618"]
68
}

dist/schema.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35184,6 +35184,28 @@
3518435184
"null"
3518535185
],
3518635186
"properties": {
35187+
"small": {
35188+
"description": "Details about the small preview version of the attachment.",
35189+
"oneOf": [
35190+
{
35191+
"$ref": "#/components/schemas/MetaDetails"
35192+
},
35193+
{
35194+
"type": "null"
35195+
}
35196+
]
35197+
},
35198+
"original": {
35199+
"description": "Details about the original version of the attachment.",
35200+
"oneOf": [
35201+
{
35202+
"$ref": "#/components/schemas/MetaDetails"
35203+
},
35204+
{
35205+
"type": "null"
35206+
}
35207+
]
35208+
},
3518735209
"focus": {
3518835210
"description": "Coordinates that may be used for smart thumbnail cropping -- see [Focal points for cropped media thumbnails]({{< relref \"api/guidelines#focal-points\" >}}) for more.",
3518935211
"type": [
@@ -35241,6 +35263,58 @@
3524135263
"description": "Official Mastodon API documentation"
3524235264
}
3524335265
},
35266+
"MetaDetails": {
35267+
"type": "object",
35268+
"description": "Additional entity definition for MetaDetails",
35269+
"properties": {
35270+
"aspect": {
35271+
"description": "The media aspect ratio of the video or image attachment.",
35272+
"type": [
35273+
"number",
35274+
"null"
35275+
]
35276+
},
35277+
"bitrate": {
35278+
"description": "The media bitrate of the video or audio attachment.",
35279+
"type": [
35280+
"integer",
35281+
"null"
35282+
]
35283+
},
35284+
"duration": {
35285+
"description": "The duration of the video attachment.",
35286+
"type": [
35287+
"number",
35288+
"null"
35289+
]
35290+
},
35291+
"frame_rate": {
35292+
"description": "The frame rate of the video attachment.",
35293+
"type": [
35294+
"string",
35295+
"null"
35296+
]
35297+
},
35298+
"height": {
35299+
"description": "The height of the attachment in pixels.",
35300+
"type": [
35301+
"integer",
35302+
"null"
35303+
]
35304+
},
35305+
"width": {
35306+
"description": "The width of the attachment in pixels.",
35307+
"type": [
35308+
"integer",
35309+
"null"
35310+
]
35311+
}
35312+
},
35313+
"externalDocs": {
35314+
"url": "https://docs.joinmastodon.org/entities/MediaAttachment/#attributes",
35315+
"description": "Official Mastodon API documentation"
35316+
}
35317+
},
3524435318
"Notification": {
3524535319
"type": "object",
3524635320
"description": "Represents a notification of an event relevant to the user.",

scripts/setup-docs.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function setupMastodonDocs(): void {
1818

1919
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
2020
const targetCommit = config.mastodonDocsCommit;
21+
const overrideCommits = config.overrideCommits || [];
22+
const overridesRepository = config.overridesRepository;
2123

2224
if (!targetCommit) {
2325
console.error('mastodonDocsCommit not found in config.json');
@@ -52,6 +54,36 @@ function setupMastodonDocs(): void {
5254
cwd: docsDir,
5355
});
5456

57+
// Apply override commits if any
58+
if (overrideCommits.length > 0) {
59+
console.log(`Adding ${overridesRepository} overrides remote...`);
60+
execSync(`git config user.email "[email protected]"`, {
61+
stdio: 'inherit',
62+
cwd: docsDir,
63+
});
64+
execSync(`git config user.name "bot"`, {
65+
stdio: 'inherit',
66+
cwd: docsDir,
67+
});
68+
execSync(`git remote add overrides ${overridesRepository} || true`, {
69+
stdio: 'inherit',
70+
cwd: docsDir,
71+
});
72+
execSync(`git fetch overrides`, {
73+
stdio: 'inherit',
74+
cwd: docsDir,
75+
});
76+
77+
console.log(`Applying ${overrideCommits.length} override commit(s)...`);
78+
for (const commit of overrideCommits) {
79+
console.log(`Cherry-picking commit ${commit}...`);
80+
execSync(`git cherry-pick ${commit}`, {
81+
stdio: 'inherit',
82+
cwd: docsDir,
83+
});
84+
}
85+
}
86+
5587
console.log('Mastodon documentation setup complete.');
5688
} catch (error) {
5789
console.error(

src/__tests__/parsers/EntityParser.draft.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ describe('EntityParser - Draft File Handling', () => {
4040
// This test validates that only explicit draft: true is filtered
4141
// This is implicitly tested by checking that we still get a reasonable number of entities
4242
const entities = parser.parseAllEntities();
43-
expect(entities.length).toBe(91); // Exact count after removing EncryptedMessage and entities from blocked files (increased due to extracted nested entities + Admin::DimensionData + DiscoverOauthServerConfigurationResponse + OEmbedResponse)
43+
expect(entities.length).toBe(92); // Exact count after removing EncryptedMessage and entities from blocked files (increased due to extracted nested entities + Admin::DimensionData + DiscoverOauthServerConfigurationResponse + OEmbedResponse)
4444
});
4545
});

src/parsers/EntityFileParser.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,35 @@ export class EntityFileParser {
157157

158158
// Find the content for this entity (from this heading to the next ## heading or end of file)
159159
const startIndex = match.index + fullMatch.length;
160-
const nextSectionMatch = content.substring(startIndex).match(/\n## /);
161-
const endIndex = nextSectionMatch
162-
? startIndex + (nextSectionMatch.index || 0)
163-
: content.length;
160+
161+
// Check if the next section is an "## Attributes" heading
162+
// If so, we need to include it in the entity content
163+
let endIndex = content.length;
164+
const remainingContent = content.substring(startIndex);
165+
const nextAttributesMatch =
166+
remainingContent.match(/\n## Attributes\s*\n/);
167+
168+
if (nextAttributesMatch && nextAttributesMatch.index !== undefined) {
169+
// Found "## Attributes" - find the section after that
170+
const afterAttributesStart =
171+
startIndex +
172+
nextAttributesMatch.index +
173+
nextAttributesMatch[0].length;
174+
const afterAttributesContent =
175+
content.substring(afterAttributesStart);
176+
const nextSectionMatch = afterAttributesContent.match(/\n## /);
177+
178+
if (nextSectionMatch && nextSectionMatch.index !== undefined) {
179+
endIndex = afterAttributesStart + nextSectionMatch.index;
180+
}
181+
// If no next section found, use the rest of the file (endIndex already set to content.length)
182+
} else {
183+
// No "## Attributes" section found, look for next ## heading
184+
const nextSectionMatch = remainingContent.match(/\n## /);
185+
if (nextSectionMatch && nextSectionMatch.index !== undefined) {
186+
endIndex = startIndex + nextSectionMatch.index;
187+
}
188+
}
164189

165190
const entityContent = content.substring(startIndex, endIndex);
166191

0 commit comments

Comments
 (0)