@@ -67,16 +67,7 @@ markdown_to_manpage(Markdown, Path, Section) ->
6767 markdown_to_manpage1 (shell_docs_markdown :parse_md (Markdown ), Path , Section ).
6868markdown_to_manpage1 (MarkdownChunks , Path , Section ) ->
6969 Path1 = filename :absname (Path ),
70- App = case filename :split (string :prefix (Path1 , os :getenv (" ERL_TOP" ))) of
71- [" /" , " lib" , AppStr | _ ] ->
72- list_to_atom (AppStr );
73- [" lib" , AppStr | _ ] ->
74- list_to_atom (AppStr );
75- [" /" , " erts" | _ ] ->
76- list_to_atom (" erts" );
77- [" nomatch" ] ->
78- error (" ERL_TOP environment variable doesn't match the PATH " ++ Path )
79- end ,
70+ App = get_app (Path1 ),
8071 Version = case application :load (App ) of
8172 ok -> {ok ,Vsn } = application :get_key (App , vsn ), Vsn ;
8273 {error , {" no such file or directory" ," erts.app" }} -> erlang :system_info (version );
@@ -91,6 +82,19 @@ markdown_to_manpage1(MarkdownChunks, Path, Section) ->
9182 I = conv (MarkdownChunks , Name ),
9283 iolist_to_binary ([Prelude |I ]).
9384
85+ get_app (Path ) ->
86+ case string :split (Path , " /erts/" ) of
87+ [_ , _ ] -> list_to_atom (" erts" );
88+ _ -> case string :split (Path , " /lib/" ) of
89+ [_ , Rest ] ->
90+ case string :split (Rest , " /" ) of
91+ [AppStr , _ ] -> list_to_atom (AppStr );
92+ _ -> error (" Could not find app from path " ++ Path )
93+ end ;
94+ _ -> error (" Could not find app from path " ++ Path )
95+ end
96+ end .
97+
9498get_name ([{h1 ,_ ,[Name ]}|_ ], _ ) when is_binary (Name ) ->
9599 Name ;
96100get_name (_ , Default ) when is_binary (Default ) ->
0 commit comments