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