@@ -127,20 +127,35 @@ pub struct ManualEntry {
127127}
128128
129129impl ManualEntry {
130+ /// Generate the identifier and title for CommonMark.
131+ /// title is the human-readable name of the function.
132+ /// ident is used as URL Encoded link to the function and has thus stricter rules (i.e. "' " in "lib.map' " is not allowed).
133+ pub ( crate ) fn get_ident_title ( & self ) -> ( String , String ) {
134+ let name_prime = self . name . replace ( '\'' , "-prime" ) ;
135+
136+ let ident = vec ! [ & self . prefix, & self . category, & name_prime]
137+ . into_iter ( )
138+ . filter ( |x| !x. is_empty ( ) )
139+ . cloned ( )
140+ . collect :: < Vec < String > > ( )
141+ . join ( "." ) ;
142+
143+ let title = vec ! [ & self . prefix, & self . category, & self . name]
144+ . into_iter ( )
145+ . filter ( |x| !x. is_empty ( ) )
146+ . cloned ( )
147+ . collect :: < Vec < String > > ( )
148+ . join ( "." ) ;
149+
150+ ( ident, title)
151+ }
130152 /// Write a single CommonMark entry for a documented Nix function.
131153 pub fn write_section < W : Write > (
132154 self ,
133155 locs : & HashMap < String , String > ,
134156 writer : & mut W ,
135157 ) -> Result < ( ) > {
136- let title = format ! ( "{}.{}.{}" , self . prefix, self . category, self . name) ;
137- let ident = format ! (
138- "{}.{}.{}" ,
139- self . prefix,
140- self . category,
141- self . name. replace( '\'' , "-prime" )
142- ) ;
143-
158+ let ( ident, title) = self . get_ident_title ( ) ;
144159 writeln ! ( writer, "## `{}` {{#function-library-{}}}\n " , title, ident) ?;
145160
146161 // <subtitle> (type signature)
0 commit comments