Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"mastodonDocsCommit": "f760ffcdf3371a641ba5d731dd33348fc6eb4fe6",
"mastodonVersion": "4.4.0",
"minimumMastodonVersion": "4.2.0",
"blockedFiles": ["methods/notifications_alpha.md"]
"blockedFiles": ["methods/notifications_alpha.md"],
"overridesRepository": "https://github.com/abraham/documentation",
"overrideCommits": ["b1d8f95b506e2d734876ef47ec0f4e1feb4f5618"]
}
74 changes: 74 additions & 0 deletions dist/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10643,7 +10643,7 @@
]
}
},
"/api/v2/filters/keywords/{id}": {

Check warning on line 10646 in dist/schema.json

View workflow job for this annotation

GitHub Actions / test

no-ambiguous-paths

Paths should resolve unambiguously. Found two ambiguous paths: `/api/v2/filters/{filter_id}/keywords` and `/api/v2/filters/keywords/{id}`.
"get": {
"operationId": "getFiltersKeywordsByIdV2",
"summary": "View a single keyword",
Expand Down Expand Up @@ -11095,7 +11095,7 @@
]
}
},
"/api/v2/filters/statuses/{id}": {

Check warning on line 11098 in dist/schema.json

View workflow job for this annotation

GitHub Actions / test

no-ambiguous-paths

Paths should resolve unambiguously. Found two ambiguous paths: `/api/v2/filters/{filter_id}/keywords` and `/api/v2/filters/statuses/{id}`.
"get": {
"operationId": "getFiltersStatusesByIdV2",
"summary": "View a single status filter",
Expand Down Expand Up @@ -35184,6 +35184,28 @@
"null"
],
"properties": {
"small": {
"description": "Details about the small preview version of the attachment.",
"oneOf": [
{
"$ref": "#/components/schemas/MetaDetails"
},
{
"type": "null"
}
]
},
"original": {
"description": "Details about the original version of the attachment.",
"oneOf": [
{
"$ref": "#/components/schemas/MetaDetails"
},
{
"type": "null"
}
]
},
"focus": {
"description": "Coordinates that may be used for smart thumbnail cropping -- see [Focal points for cropped media thumbnails]({{< relref \"api/guidelines#focal-points\" >}}) for more.",
"type": [
Expand Down Expand Up @@ -35241,6 +35263,58 @@
"description": "Official Mastodon API documentation"
}
},
"MetaDetails": {
"type": "object",
"description": "Additional entity definition for MetaDetails",
"properties": {
"aspect": {
"description": "The media aspect ratio of the video or image attachment.",
"type": [
"number",
"null"
]
},
"bitrate": {
"description": "The media bitrate of the video or audio attachment.",
"type": [
"integer",
"null"
]
},
"duration": {
"description": "The duration of the video attachment.",
"type": [
"number",
"null"
]
},
"frame_rate": {
"description": "The frame rate of the video attachment.",
"type": [
"string",
"null"
]
},
"height": {
"description": "The height of the attachment in pixels.",
"type": [
"integer",
"null"
]
},
"width": {
"description": "The width of the attachment in pixels.",
"type": [
"integer",
"null"
]
}
},
"externalDocs": {
"url": "https://docs.joinmastodon.org/entities/MediaAttachment/#attributes",
"description": "Official Mastodon API documentation"
}
},
"Notification": {
"type": "object",
"description": "Represents a notification of an event relevant to the user.",
Expand Down
32 changes: 32 additions & 0 deletions scripts/setup-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function setupMastodonDocs(): void {

const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
const targetCommit = config.mastodonDocsCommit;
const overrideCommits = config.overrideCommits || [];
const overridesRepository = config.overridesRepository;

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

// Apply override commits if any
if (overrideCommits.length > 0) {
console.log(`Adding ${overridesRepository} overrides remote...`);
execSync(`git config user.email "[email protected]"`, {
stdio: 'inherit',
cwd: docsDir,
});
execSync(`git config user.name "bot"`, {
stdio: 'inherit',
cwd: docsDir,
});
execSync(`git remote add overrides ${overridesRepository} || true`, {
stdio: 'inherit',
cwd: docsDir,
});
execSync(`git fetch overrides`, {
stdio: 'inherit',
cwd: docsDir,
});

console.log(`Applying ${overrideCommits.length} override commit(s)...`);
for (const commit of overrideCommits) {
console.log(`Cherry-picking commit ${commit}...`);
execSync(`git cherry-pick ${commit}`, {
stdio: 'inherit',
cwd: docsDir,
});
}
}

console.log('Mastodon documentation setup complete.');
} catch (error) {
console.error(
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/parsers/EntityParser.draft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ describe('EntityParser - Draft File Handling', () => {
// This test validates that only explicit draft: true is filtered
// This is implicitly tested by checking that we still get a reasonable number of entities
const entities = parser.parseAllEntities();
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)
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)
});
});
33 changes: 29 additions & 4 deletions src/parsers/EntityFileParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,35 @@ export class EntityFileParser {

// Find the content for this entity (from this heading to the next ## heading or end of file)
const startIndex = match.index + fullMatch.length;
const nextSectionMatch = content.substring(startIndex).match(/\n## /);
const endIndex = nextSectionMatch
? startIndex + (nextSectionMatch.index || 0)
: content.length;

// Check if the next section is an "## Attributes" heading
// If so, we need to include it in the entity content
let endIndex = content.length;
const remainingContent = content.substring(startIndex);
const nextAttributesMatch =
remainingContent.match(/\n## Attributes\s*\n/);

if (nextAttributesMatch && nextAttributesMatch.index !== undefined) {
// Found "## Attributes" - find the section after that
const afterAttributesStart =
startIndex +
nextAttributesMatch.index +
nextAttributesMatch[0].length;
const afterAttributesContent =
content.substring(afterAttributesStart);
const nextSectionMatch = afterAttributesContent.match(/\n## /);

if (nextSectionMatch && nextSectionMatch.index !== undefined) {
endIndex = afterAttributesStart + nextSectionMatch.index;
}
// If no next section found, use the rest of the file (endIndex already set to content.length)
} else {
// No "## Attributes" section found, look for next ## heading
const nextSectionMatch = remainingContent.match(/\n## /);
if (nextSectionMatch && nextSectionMatch.index !== undefined) {
endIndex = startIndex + nextSectionMatch.index;
}
}

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

Expand Down