fix: use indent check to avoid parsing params as modules/subsystems
This commit is contained in:
@@ -52,15 +52,17 @@ function parseSubsystems(yaml: string): Subsystem[] {
|
||||
|
||||
let current: Partial<Subsystem> = {};
|
||||
let currentField: string | null = null;
|
||||
let inSubsystem = false;
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
const indent = line.search(/\S/);
|
||||
|
||||
if (trimmed.startsWith('subsystems:')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trimmed.startsWith('- name:')) {
|
||||
if (trimmed.startsWith('- name:') && indent <= 2) {
|
||||
if (current.name) {
|
||||
subsystems.push({
|
||||
id: current.name,
|
||||
@@ -77,11 +79,12 @@ function parseSubsystems(yaml: string): Subsystem[] {
|
||||
provides: [],
|
||||
depends_on: []
|
||||
};
|
||||
inSubsystem = true;
|
||||
currentField = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!current.name) continue;
|
||||
if (!inSubsystem || !current.name) continue;
|
||||
|
||||
if (trimmed.startsWith('responsibilities:')) {
|
||||
currentField = 'responsibilities';
|
||||
@@ -164,15 +167,17 @@ function parseModules(yaml: string): Module[] {
|
||||
let currentApi: Module['public_api'][0] | null = null;
|
||||
let inPublicApi = false;
|
||||
let inParams = false;
|
||||
let inModule = false;
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
const indent = line.search(/\S/);
|
||||
|
||||
if (trimmed.startsWith('modules:')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trimmed.startsWith('- name:')) {
|
||||
if (trimmed.startsWith('- name:') && indent <= 2) {
|
||||
if (current.name && current.parent_subsystem) {
|
||||
modules.push({
|
||||
id: current.name,
|
||||
@@ -188,13 +193,14 @@ function parseModules(yaml: string): Module[] {
|
||||
responsibility: '',
|
||||
public_api: []
|
||||
};
|
||||
inModule = true;
|
||||
inPublicApi = false;
|
||||
inParams = false;
|
||||
currentApi = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!current.name) continue;
|
||||
if (!inModule || !current.name) continue;
|
||||
|
||||
if (trimmed.startsWith('parent_subsystem:')) {
|
||||
current.parent_subsystem = trimmed.replace('parent_subsystem:', '').trim();
|
||||
|
||||
Reference in New Issue
Block a user