diff options
author | Lukas Larsson <[email protected]> | 2018-04-12 10:16:41 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2018-04-12 10:16:41 +0200 |
commit | 0f4e092e58929a9a517eb17653f4ec217f2a9132 (patch) | |
tree | d7f9ecebec69ebf5f08018b60113a45f78453213 /lib/erl_docgen/priv/bin/github_link.escript | |
parent | cb9fb22d0798f162c8a580d2f6751d7de0ae63dd (diff) | |
parent | a26796d0552c737baf26e4916e8d9014215bc301 (diff) | |
download | otp-0f4e092e58929a9a517eb17653f4ec217f2a9132.tar.gz otp-0f4e092e58929a9a517eb17653f4ec217f2a9132.tar.bz2 otp-0f4e092e58929a9a517eb17653f4ec217f2a9132.zip |
Merge branch 'lukas/erl_docgen/add_github_contrib_link/OTP-14979'
* lukas/erl_docgen/add_github_contrib_link/OTP-14979:
erl_docgen: Remove git dependency in github link script
stdlib: Fix timer monotonic time link
erl_docgen: Use name based anchors where possible
erl_docgen: Change ghlink icon to pencil
erl_docgen: Fix ghlinks to .xmlsrc
erl_docgen: Add hover links for ghlink
erl_docgen: Add ghlink step for all non-generated doc xml files
Fix erlang:abs/2 type docs
Tickets missed in 9033a41375f3a31a18eb0cba3ea
OTP-14651: temp_alloc disabling
OTP-14652: msacc bugs
Diffstat (limited to 'lib/erl_docgen/priv/bin/github_link.escript')
-rwxr-xr-x | lib/erl_docgen/priv/bin/github_link.escript | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/erl_docgen/priv/bin/github_link.escript b/lib/erl_docgen/priv/bin/github_link.escript new file mode 100755 index 0000000000..1b36fca202 --- /dev/null +++ b/lib/erl_docgen/priv/bin/github_link.escript @@ -0,0 +1,51 @@ +#!/usr/bin/env escript +%% -*- erlang -*- +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2010-2016. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%%---------------------------------------------------------------------- +%% File : github_link.escript +%% +%% Created : 12 Dec 2017 by Lukas Larsson +%%---------------------------------------------------------------------- + +main([In, Filename, Sha, Out]) -> + {ok, Bin} = file:read_file(In), + + TagsToAnnotate = ["description", "func", "datatype", "section"], + + Subs = subs(TagsToAnnotate, Filename, Sha, re:split(Bin,[$\n])), + + file:write_file(Out, Subs). + +subs([], _, _, Bin) -> + lists:join("\n", Bin); +subs([Pat|Pats], Fn, Sha, Bin) -> + subs(Pats, Fn, Sha, sub(Bin, Pat, Fn, Sha)). + +sub(Bin, Pat, Fn, Sha) -> + sub(Bin, Pat, Fn, Sha, 1). +sub([], _Pat, _Fn, _Sha, _Cnt) -> + []; +sub([H|T], Pat, Fn, Sha, Cnt) -> + %% We use the maint branch here, it is not as exact as the tag, + %% but it is the best we can do as github does not allow doing + %% pullrequests on anything but branches. + [re:replace(H,["<",Pat,">"], + ["<",Pat," ghlink=\"maint/",Fn,"#L", + integer_to_list(Cnt),"\">"],[{return,list}]) | + sub(T, Pat, Fn, Sha, Cnt+1)]. |