@@ -23,33 +23,34 @@ import { buildMetaBarProps } from './buildBarProps.mjs';
2323 * @param {import('unist').Parent } parent - The parent node containing the stability node
2424 * @returns {[typeof SKIP] } Visitor instruction to skip the node
2525 */
26- function transformStabilityNode ( node , index , parent ) {
27- const { data } = node ;
26+ const transformStabilityNode = ( { data } , index , parent ) => {
2827 parent . children [ index ] = createJSXElement ( 'AlertBox' , {
2928 children : data . description ,
3029 level : STABILITY_LEVELS [ data . index ] ,
3130 title : data . index ,
3231 } ) ;
32+
3333 return [ SKIP ] ;
34- }
34+ } ;
3535
3636/**
3737 * Creates a history of changes for an API element
3838 *
3939 * @param {ApiDocMetadataEntry } entry - The metadata entry containing change information
4040 * @returns {import('unist').Node|null } JSX element representing change history or null if no changes
4141 */
42- function createChangeElement ( entry ) {
42+ const createChangeElement = entry => {
4343 // Collect changes from version fields (added, deprecated, etc.)
4444 const changeEntries = Object . entries ( CHANGE_TYPES )
45+ // Do we have this field?
4546 . filter ( ( [ field ] ) => entry [ field ] )
46- . map ( ( [ field , label ] ) => {
47- const versions = enforceArray ( entry [ field ] ) ;
48- return {
49- versions ,
50- label : ` ${ label } : ${ versions . join ( ', ' ) } ` ,
51- } ;
52- } ) ;
47+ // Get the versions as an array
48+ . map ( ( [ field , label ] ) => [ enforceArray ( entry [ field ] ) , label ] )
49+ // Create the change entry
50+ . map ( ( [ versions , label ] ) => ( {
51+ versions,
52+ label : ` ${ label } : ${ versions . join ( ', ' ) } ` ,
53+ } ) ) ;
5354
5455 // Add explicit changes if they exist
5556 if ( entry . changes ?. length ) {
@@ -61,22 +62,26 @@ function createChangeElement(entry) {
6162 changeEntries . push ( ...explicitChanges ) ;
6263 }
6364
64- if ( ! changeEntries . length ) return null ;
65+ if ( ! changeEntries . length ) {
66+ return null ;
67+ }
6568
6669 // Sort by version, newest first and create the JSX element
6770 return createJSXElement ( 'ChangeHistory' , {
6871 changes : sortChanges ( changeEntries , 'versions' ) ,
6972 } ) ;
70- }
73+ } ;
7174
7275/**
7376 * Creates a source link element if a source link is available
7477 *
7578 * @param {string|undefined } sourceLink - The source link path
7679 * @returns {import('hastscript').Element|null } The source link element or null if no source link
7780 */
78- function createSourceLink ( sourceLink ) {
79- if ( ! sourceLink ) return null ;
81+ const createSourceLink = sourceLink => {
82+ if ( ! sourceLink ) {
83+ return null ;
84+ }
8085
8186 return createElement ( 'span' , [
8287 'Source Code: ' ,
@@ -86,7 +91,7 @@ function createSourceLink(sourceLink) {
8691 sourceLink
8792 ) ,
8893 ] ) ;
89- }
94+ } ;
9095
9196/**
9297 * Enhances a heading node with metadata, source links, and styling
@@ -97,7 +102,7 @@ function createSourceLink(sourceLink) {
97102 * @param {import('unist').Parent } parent - The parent node containing the heading
98103 * @returns {[typeof SKIP] } Visitor instruction to skip the node
99104 */
100- function transformHeadingNode ( entry , node , index , parent ) {
105+ const transformHeadingNode = ( entry , node , index , parent ) => {
101106 const { data, children } = node ;
102107 const headerChildren = [
103108 createElement ( `h${ data . depth + 1 } ` , [
@@ -127,15 +132,15 @@ function transformHeadingNode(entry, node, index, parent) {
127132 }
128133
129134 return [ SKIP ] ;
130- }
135+ } ;
131136
132137/**
133138 * Processes an API documentation entry by applying transformations to its content
134139 *
135140 * @param {ApiDocMetadataEntry } entry - The API metadata entry to process
136141 * @returns {import('unist').Node } The processed content
137142 */
138- function processEntry ( entry ) {
143+ const processEntry = entry => {
139144 // Create a copy to avoid modifying the original
140145 const content = structuredClone ( entry . content ) ;
141146
@@ -146,7 +151,7 @@ function processEntry(entry) {
146151 ) ;
147152
148153 return content ;
149- }
154+ } ;
150155
151156/**
152157 * Creates the overall content structure with processed entries
@@ -156,7 +161,7 @@ function processEntry(entry) {
156161 * @param {Object } metaBarProps - Props for the meta bar component
157162 * @returns {import('unist').Node } The root node of the content tree
158163 */
159- function createContentStructure ( entries , sideBarProps , metaBarProps ) {
164+ const createContentStructure = ( entries , sideBarProps , metaBarProps ) => {
160165 return createTree ( 'root' , [
161166 createJSXElement ( 'NavBar' ) ,
162167 createJSXElement ( 'Article' , {
@@ -170,7 +175,7 @@ function createContentStructure(entries, sideBarProps, metaBarProps) {
170175 ] ,
171176 } ) ,
172177 ] ) ;
173- }
178+ } ;
174179
175180/**
176181 * Transforms API metadata entries into processed MDX content
@@ -181,12 +186,7 @@ function createContentStructure(entries, sideBarProps, metaBarProps) {
181186 * @param {import('unified').Processor } remark - Remark processor instance for markdown processing
182187 * @returns {string } The stringified MDX content
183188 */
184- export default function buildContent (
185- metadataEntries ,
186- head ,
187- sideBarProps ,
188- remark
189- ) {
189+ const buildContent = ( metadataEntries , head , sideBarProps , remark ) => {
190190 const metaBarProps = buildMetaBarProps ( head , metadataEntries ) ;
191191
192192 const root = createContentStructure (
@@ -196,4 +196,6 @@ export default function buildContent(
196196 ) ;
197197
198198 return remark . runSync ( root ) ;
199- }
199+ } ;
200+
201+ export default buildContent ;
0 commit comments