@@ -8,15 +8,7 @@ import * as BindingInfo from './BindingInfo';
88// linkification
99// ----------------------------------------------------------------------------
1010
11- const aliasPath = ( doc : AliasCopy ) => {
12- if ( doc . doctype === 'constant' ) return doc . enum + '/' + doc . partialName ;
13- if ( doc . doctype === 'namespace' ) return doc . name ;
14- return (
15- ( O . isSome ( doc . namespace ) ? doc . namespace . value + '/' : '' ) + doc . partialName
16- ) ;
17- } ;
18-
19- export const mainUrl = ( doc : sf . Topic ) =>
11+ export const url = ( doc : sf . Topic ) =>
2012 pipe (
2113 doc . filepath ,
2214 // slice to remove the '.yml' extension
@@ -26,11 +18,6 @@ export const mainUrl = (doc: sf.Topic) =>
2618 O . getOrElse ( ( ) => '#' )
2719 ) ;
2820
29- export const url = ( doc : sf . Topic ) =>
30- 'source' in doc && isAliasCopy ( doc )
31- ? '/api/' + doc . doctype + 's/' + aliasPath ( doc )
32- : mainUrl ( doc ) ;
33-
3421export const linkify =
3522 ( content : md . Children < md . Link > ) =>
3623 ( doc : sf . Topic ) : md . Link =>
@@ -60,7 +47,9 @@ export const tagsSection =
6047
6148const summaryListItem = ( doc : sf . Topic ) : md . ListItem =>
6249 pipe (
63- doc . summary ,
50+ 'source' in doc && isAliasCopy ( doc )
51+ ? O . some ( aliasSummary ( doc ) )
52+ : doc . summary ,
6453 O . map ( ( a ) =>
6554 md . paragraph ( [ linkedNameCode ( doc ) , md . text ( ' - ' ) , ...a . children ] )
6655 ) ,
@@ -108,18 +97,33 @@ export const getAliasCopies = <T extends Aliasable>(
10897 ) ;
10998} ;
11099
100+ export const aliasSummary = ( alias : AliasCopy ) => {
101+ const status =
102+ ( alias . status . index === 'stable' ? '' : alias . status . index + ' ' ) +
103+ 'alias of' ;
104+ return md . paragraph ( [
105+ md . text ( status [ 0 ] ! . toUpperCase ( ) + status . slice ( 1 ) ) ,
106+ md . link ( url ( alias ) , O . none , [ md . inlineCode ( alias . aliasOf . value ) ] ) ,
107+ md . text ( '.' ) ,
108+ ] ) ;
109+ } ;
110+
111+ // TODO: remove this and its calls
111112export const aliasPage = ( alias : AliasCopy ) : md . Root =>
112113 md . root ( [
113114 md . simpleHeading ( 1 ) ( alias . name ) ,
114115 md . paragraph ( [
115116 md . text ( 'This is an alias of ' ) ,
116- md . link ( mainUrl ( alias ) , O . none , [ md . inlineCode ( alias . aliasOf . value ) ] ) ,
117+ md . link ( url ( alias ) , O . none , [ md . inlineCode ( alias . aliasOf . value ) ] ) ,
117118 md . text ( '.' ) ,
118119 ] ) ,
119120 ] ) ;
120121
121- const aliasNameString = ( doc : sf . BindingInfo ) : md . PhrasingContent =>
122- BindingInfo . strikeBasedOnStatus ( doc ) ( md . text ( doc . name ) ) ;
122+ const aliasNameString = ( doc : sf . BindingInfo ) : md . Children < md . Paragraph > => {
123+ const name = BindingInfo . strikeBasedOnStatus ( doc ) ( md . inlineCode ( doc . name ) ) ;
124+ if ( doc . status . index === 'stable' ) return [ name ] ;
125+ return [ name , ...md . superscript ( [ md . text ( doc . status . index ) ] ) ] ;
126+ } ;
123127
124128export const aliasesSection =
125129 ( allEntries : RR . ReadonlyRecord < string , Aliasable > ) =>
@@ -128,7 +132,8 @@ export const aliasesSection =
128132 aliases ,
129133 RA . filterMap ( ( a ) => RR . lookup ( a . name ) ( allEntries ) ) ,
130134 RA . map ( aliasNameString ) ,
131- RA . intersperse < md . PhrasingContent > ( md . text ( ', ' ) ) ,
135+ RA . intersperse < md . Children < md . Paragraph > > ( [ md . text ( ', ' ) ] ) ,
136+ RA . flatten ,
132137 RNEA . fromReadonlyArray ,
133138 O . map ( ( a ) =>
134139 md . paragraph ( [ md . bold ( [ md . text ( 'aliases:' ) ] ) , md . text ( ' ' ) , ...a ] )
0 commit comments