parseAstro.ts — astro Source File
Architecture documentation for parseAstro.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9["parseAstro.ts"] 1c830673_d3fc_59eb_ee93_023dd3e6e9ac["./astro2tsx.js"] 0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9 --> 1c830673_d3fc_59eb_ee93_023dd3e6e9ac 881bedca_8bf1_6c82_1d1d_caae9da803fd["sync"] 0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9 --> 881bedca_8bf1_6c82_1d1d_caae9da803fd 81a20ac1_6143_16be_33ec_872bb8d3a54b["types"] 0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9 --> 81a20ac1_6143_16be_33ec_872bb8d3a54b style 0fc8da77_17d5_93f4_f8a7_0d74e4ce41d9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { parse } from '@astrojs/compiler/sync';
import type { ParseOptions, ParseResult, Point } from '@astrojs/compiler/types';
import type { LSPTSXRanges } from './astro2tsx.js';
export type AstroMetadata = ParseResult & {
frontmatter: FrontmatterStatus;
tsxRanges: LSPTSXRanges;
};
export function getAstroMetadata(
fileName: string,
input: string,
options: ParseOptions = { position: true },
): Omit<AstroMetadata, 'tsxRanges'> {
const parseResult = safeParseAst(fileName, input, options);
return {
...parseResult,
frontmatter: getFrontmatterStatus(parseResult.ast, input),
};
}
function safeParseAst(fileName: string, input: string, parseOptions: ParseOptions): ParseResult {
try {
const parseResult = parse(input, parseOptions);
return parseResult;
} catch (e) {
console.error(
`There was an error parsing ${fileName}'s AST. An empty AST will be returned instead to avoid breaking the server. Please create an issue: https://github.com/withastro/astro/issues\nError: ${e}.`,
);
return {
ast: {
type: 'root',
children: [],
},
diagnostics: [
{
code: 1000,
location: {
file: fileName,
line: 1,
column: 1,
length: input.length,
},
severity: 1,
text: `The Astro compiler encountered an unknown error while parsing this file's AST. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/astro/issues`,
},
],
};
}
}
interface FrontmatterOpen {
status: 'open';
position: {
start: Point;
end: undefined;
};
}
// ... (65 more lines)
Domain
Subdomains
Dependencies
- ./astro2tsx.js
- sync
- types
Source
Frequently Asked Questions
What does parseAstro.ts do?
parseAstro.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in parseAstro.ts?
parseAstro.ts defines 3 function(s): getAstroMetadata, getFrontmatterStatus, safeParseAst.
What does parseAstro.ts depend on?
parseAstro.ts imports 3 module(s): ./astro2tsx.js, sync, types.
Where is parseAstro.ts in the architecture?
parseAstro.ts is located at packages/language-tools/language-server/src/core/parseAstro.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/language-tools/language-server/src/core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free