@@ -3,95 +3,36 @@ import path from 'node:path';
33
44import {
55 OUTPUT_DIRECTORY_NAME ,
6- OUTPUT_FILENAME_EXPO_DOCS ,
7- TITLE ,
8- DESCRIPTION ,
9- generateSectionMarkdown ,
10- processSection ,
11- readFrontmatter ,
12- } from './utils .js' ;
6+ collectPageHrefs ,
7+ composeMarkdownDocument ,
8+ ensureBuildOutputDir ,
9+ getMarkdownPathFromHref ,
10+ readUniqueMarkdownContent ,
11+ uniqueInternalHrefs ,
12+ } from './shared .js' ;
1313import { home , learn , general } from '../../constants/navigation.js' ;
1414
15- function readInstructions ( ) {
16- const instructionsDir = path . join (
17- process . cwd ( ) ,
18- 'scenes/get-started/set-up-your-environment/instructions'
19- ) ;
15+ const OUTPUT_FILENAME_EXPO_DOCS = 'llms-full.txt' ;
16+ const TITLE = 'Expo Documentation' ;
17+ const DESCRIPTION =
18+ 'Expo is an open-source React Native framework for apps that run natively on Android, iOS, and the web. Expo brings together the best of mobile and the web and enables many important features for building and scaling an app such as live updates, instantly sharing your app, and web support. The company behind Expo also offers Expo Application Services (EAS), which are deeply integrated cloud services for Expo and React Native apps.' ;
2019
21- const headerMapping = {
22- _androidEmulatorInstructions : 'Android Emulator Setup' ,
23- _androidStudioEnvironmentInstructions : 'Android Studio Environment Setup' ,
24- _androidStudioInstructions : 'Android Studio Setup' ,
25- _xcodeInstructions : 'Xcode Setup' ,
26- androidPhysicalDevelopmentBuild :
27- 'Create a development build for a physical Android device with EAS' ,
28- androidPhysicalDevelopmentBuildLocal :
29- 'Create a development build for a physical Android device locally' ,
30- androidPhysicalExpoGo : 'Run on a physical Android device with Expo Go' ,
31- androidSimulatedDevelopmentBuild : 'Create a development build for Android Emulator with EAS' ,
32- androidSimulatedDevelopmentBuildLocal :
33- 'Create a development build for Android Emulator locally' ,
34- androidSimulatedExpoGo : 'Run on Android Emulator with Expo Go' ,
35- iosPhysicalDevelopmentBuild : 'Create a development build for a physical iOS device with EAS' ,
36- iosPhysicalDevelopmentBuildLocal :
37- 'Create a development build for a physical iOS device locally' ,
38- iosPhysicalExpoGo : 'Run on a physical iOS device with Expo Go' ,
39- iosSimulatedDevelopmentBuild : 'Create a development build for iOS Simulator with EAS' ,
40- iosSimulatedDevelopmentBuildLocal : 'Create a development build for iOS Simulator locally' ,
41- iosSimulatedExpoGo : 'Run on iOS Simulator with Expo Go' ,
42- } ;
20+ function generateFullMarkdown ( { title, description } ) {
21+ const buildDir = ensureBuildOutputDir ( ) ;
22+ const allHrefs = uniqueInternalHrefs ( collectPageHrefs ( [ ...home , ...learn , ...general ] ) ) ;
23+ const markdownPaths = allHrefs . map ( href => getMarkdownPathFromHref ( buildDir , href ) ) ;
24+ const contentChunks = readUniqueMarkdownContent ( markdownPaths , { warnOnMissing : true } ) ;
4325
44- const instructionFiles = Object . keys ( headerMapping ) ;
45-
46- return instructionFiles
47- . map ( filename => {
48- const filePath = path . join ( instructionsDir , `${ filename } .mdx` ) ;
49- if ( fs . existsSync ( filePath ) ) {
50- const { title, content } = readFrontmatter ( filePath ) ;
51- const header = headerMapping [ filename ] || title || filename ;
52- return `# ${ header } \n\n${ content } \n\n` ;
53- }
54- return '' ;
55- } )
56- . join ( '' ) ;
57- }
58-
59- function processEnvironmentPage ( section ) {
60- if ( section . items ) {
61- section . items = section . items . map ( item => {
62- if ( item . url && item . url . includes ( 'set-up-your-environment' ) ) {
63- const instructions = readInstructions ( ) ;
64- item . content = item . content . replace ( '<DevelopmentEnvironmentInstructions />' , instructions ) ;
65- }
66- return item ;
67- } ) ;
68- }
69-
70- if ( section . sections ) {
71- section . sections = section . sections . map ( processEnvironmentPage ) ;
72- }
73-
74- return section ;
75- }
76-
77- function generateFullMarkdown ( { title, description, sections } ) {
78- return `# ${ title } \n\n${ description } \n\n` + sections . map ( generateSectionMarkdown ) . join ( '' ) ;
26+ return composeMarkdownDocument ( { title, description, contentChunks } ) ;
7927}
8028
8129export async function generateLlmsFullTxt ( ) {
8230 try {
83- const sections = [
84- ...home . map ( section => ( { ...processSection ( section ) , category : 'Home' } ) ) ,
85- ...learn . map ( section => ( { ...processSection ( section ) , category : 'Learn' } ) ) ,
86- ...general . map ( section => ( { ...processSection ( section ) , category : 'General' } ) ) ,
87- ] . map ( processEnvironmentPage ) ;
88-
8931 await fs . promises . writeFile (
9032 path . join ( process . cwd ( ) , OUTPUT_DIRECTORY_NAME , OUTPUT_FILENAME_EXPO_DOCS ) ,
9133 generateFullMarkdown ( {
9234 title : TITLE ,
9335 description : DESCRIPTION ,
94- sections,
9536 } )
9637 ) ;
9738
0 commit comments