packages/vue-styleguidist/loaders/utils/getSections.js
function processSection(section, config, parentDepth) {
	const contentRelativePath = section.content

	// Try to load section content file
	let content
	if (contentRelativePath) {
		const contentAbsolutePath = path.resolve(config.configDir, contentRelativePath)
		if (!fs.existsSync(contentAbsolutePath)) {
			throw new Error(`Styleguidist: Section content file not found: ${contentAbsolutePath}`)
		}
		content = requireIt(`!!${examplesLoader}?customLangs=vue|js|jsx!${contentAbsolutePath}`)
	}

	let sectionDepth

	if (parentDepth === undefined) {
		sectionDepth = section.sectionDepth !== undefined ? section.sectionDepth : 0
	} else {
		sectionDepth = parentDepth === 0 ? 0 : parentDepth - 1
	}

	return {
		name: section.name,
		exampleMode: section.exampleMode || config.exampleMode,
		usageMode: section.usageMode || config.usageMode,
		sectionDepth,
		description: section.description,
		slug: slugger.slug(section.name),
		sections: getSections(section.sections || [], config, sectionDepth),
		filepath: contentRelativePath,
		href: section.href,
		components: getSectionComponents(section, config),
		content,
		external: section.external
	}
}
function processSection(section, config, parentDepth) {
	const contentRelativePath = section.content

	// Try to load section content file
	let content
	if (contentRelativePath) {
		const contentAbsolutePath = path.resolve(config.configDir, contentRelativePath)
		if (!fs.existsSync(contentAbsolutePath)) {
			throw new Error(`Styleguidist: Section content file not found: ${contentAbsolutePath}`)
		}
		content = requireIt(`!!${examplesLoader}?customLangs=vue|js|jsx!${contentAbsolutePath}`)
	}

	let sectionDepth

	if (parentDepth === undefined) {
		sectionDepth = section.sectionDepth !== undefined ? section.sectionDepth : 0
	} else {
		sectionDepth = parentDepth === 0 ? 0 : parentDepth - 1
	}

	return {
		name: section.name,
		exampleMode: section.exampleMode || config.exampleMode,
		usageMode: section.usageMode || config.usageMode,
		sectionDepth,
		description: section.description,
		slug: slugger.slug(section.name),
		sections: getSections(section.sections || [], config, sectionDepth),
		filepath: contentRelativePath,
		href: section.href,
		components: getSectionComponents(section, config),
		content,
		external: section.external
	}
}
function processSection ( section , config , parentDepth ) { const contentRelativePath = section . content // Try to load section content file let content if ( contentRelativePath ) { const contentAbsolutePath = path . resolve ( config . configDir , contentRelativePath ) if ( ! fs . existsSync ( contentAbsolutePath ) ) { throw new Error ( ` ${ contentAbsolutePath } ` ) } content = requireIt ( ` ${ examplesLoader } ${ contentAbsolutePath } ` ) } let sectionDepth if ( parentDepth === undefined ) { sectionDepth = section . sectionDepth !== undefined ? section . sectionDepth : 0 } else { sectionDepth = parentDepth === 0 ? 0 : parentDepth - 1 } return { name : section . name , exampleMode : section . exampleMode || config . exampleMode , usageMode : section . usageMode || config . usageMode , sectionDepth , description : section . description , slug : slugger . slug ( section . name ) , sections : getSections ( section . sections || [ ] , config , sectionDepth ) , filepath : contentRelativePath , href : section . href , components : getSectionComponents ( section , config ) , content , external : section . external } }
Return an object for a given section with all components and subsections.
@param {object} section
@param {object} config
@param {number} parentDepth
@returns {object}
Return an object for a given section with all components and subsections .