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
5 changes: 5 additions & 0 deletions .github/actions/generate-mobile-docs/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Generate Mobile Docs
description: Generate mobile docs from mobile document

inputs:
platform:
description: Mobile platform to generate docs from (android | ios)
required: true

runs:
using: 'node24'
main: 'dist/index.mjs'
28 changes: 20 additions & 8 deletions .github/actions/generate-mobile-docs/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10672,6 +10672,14 @@ glob.glob = glob;

// src/modules/base.ts
var exec = __toESM(require_exec());

// src/helpers.ts
var normalizeFrontmatter = (content) => content.replace(
/^(---\n[\s\S]*?\n---)/,
(frontmatter) => frontmatter.replace(/`/g, "")
);

// src/modules/base.ts
var BaseModule = class {
tempFiles = {};
PLATFORM;
Expand Down Expand Up @@ -10703,11 +10711,7 @@ var BaseModule = class {
const designSlug = f.split("/");
return designSlug.at(designSlug.length - 2).replace(/-/g, "") === (customTitle || title);
});
let fileContent = fs.readFileSync(file, "utf8");
fileContent = fileContent.replace(
/^(---\n[\s\S]*?\n---)/,
(frontmatter) => frontmatter.replace(/`/g, "")
);
const fileContent = normalizeFrontmatter(fs.readFileSync(file, "utf8"));
if (designFile) {
this.tempFiles[designFile.replace(/design\.mdx$/, `${this.PLATFORM}.mdx`)] = fileContent;
} else {
Expand Down Expand Up @@ -10759,7 +10763,7 @@ var BaseModule = class {
if (!designFile) {
continue;
}
this.tempFiles[designFile.replace(/design\.mdx$/, `${this.PLATFORM}.mdx`)] = fs.readFileSync(file, "utf8");
this.tempFiles[designFile.replace(/design\.mdx$/, `${this.PLATFORM}.mdx`)] = normalizeFrontmatter(fs.readFileSync(file, "utf8"));
}
}
getComponentTitle(file) {
Expand Down Expand Up @@ -10861,9 +10865,17 @@ ${parsedMatter.data.description}
};

// src/index.ts
var MODULES = {
android: Android,
ios: IOS
};
var run = async () => {
(await new Android().gitClone()).load().convert().save().cleanup();
(await new IOS().gitClone()).load().convert().save().cleanup();
const platform = process.env.INPUT_PLATFORM ?? "";
const Module = MODULES[platform];
if (!Module) {
throw new Error(`Unknown platform: ${platform}`);
}
(await new Module().gitClone()).load().convert().save().cleanup();
};
run();
/*! Bundled license information:
Expand Down
8 changes: 8 additions & 0 deletions .github/actions/generate-mobile-docs/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* 모바일 문서 frontmatter의 백틱은 YAML 파싱을 깨뜨리므로 제거한다
* .github/actions/validate-docs/src/index.ts에 같은 코드가 있으므로 함께 수정한다
*/
export const normalizeFrontmatter = (content: string) =>
content.replace(/^(---\n[\s\S]*?\n---)/, (frontmatter) =>
frontmatter.replace(/`/g, ''),
);
15 changes: 13 additions & 2 deletions .github/actions/generate-mobile-docs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import Android from './modules/android';
import IOS from './modules/ios';

const MODULES: Record<string, typeof Android | typeof IOS | undefined> = {
android: Android,
ios: IOS,
};

const run = async () => {
(await new Android().gitClone()).load().convert().save().cleanup();
(await new IOS().gitClone()).load().convert().save().cleanup();
const platform = process.env.INPUT_PLATFORM ?? '';
const Module = MODULES[platform];

if (!Module) {
throw new Error(`Unknown platform: ${platform}`);
}

(await new Module().gitClone()).load().convert().save().cleanup();
};

run();
11 changes: 4 additions & 7 deletions .github/actions/generate-mobile-docs/src/modules/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import fs from 'node:fs';
import { globSync } from 'glob';
import * as exec from '@actions/exec';

import { normalizeFrontmatter } from '../helpers';

export type CustomComponentMap = Record<string, string>;
export type CopyComponentMap = Record<string, Array<string>>;

Expand Down Expand Up @@ -61,12 +63,7 @@ export default abstract class BaseModule {
);
});

let fileContent = fs.readFileSync(file, 'utf8');

fileContent = fileContent.replace(
/^(---\n[\s\S]*?\n---)/,
(frontmatter) => frontmatter.replace(/`/g, ''),
);
const fileContent = normalizeFrontmatter(fs.readFileSync(file, 'utf8'));

if (designFile) {
this.tempFiles[
Expand Down Expand Up @@ -146,7 +143,7 @@ export default abstract class BaseModule {

this.tempFiles[
designFile.replace(/design\.mdx$/, `${this.PLATFORM}.mdx`)
] = fs.readFileSync(file, 'utf8');
] = normalizeFrontmatter(fs.readFileSync(file, 'utf8'));
}
}

Expand Down
1 change: 1 addition & 0 deletions .github/actions/validate-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!dist
16 changes: 16 additions & 0 deletions .github/actions/validate-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Validate Docs
description: Compile md/mdx files the same way the docs build does and fail on errors

inputs:
files:
description: Glob patterns of md/mdx files to validate (newline separated)
required: false
default: '**/*.{md,mdx}'
mobile-source:
description: Validate original docs from a mobile repository (applies the same transform as generate-mobile-docs)
required: false
default: 'false'

runs:
using: 'node24'
main: 'dist/index.mjs'
Loading
Loading