Skip to content

Commit

Permalink
Make links fixup work
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi committed Oct 27, 2023
1 parent b3b6f9c commit 0c7b28b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion make/doc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ include $(ERL_TOP)/make/otp_release_targets.mk
release_html_spec: html
$(INSTALL_DIR) "$(RELSYS_HTMLDIR)"
$(INSTALL_DIR_DATA) "$(HTMLDIR)/" "$(RELSYS_HTMLDIR)"
$(ERL_TOP)/make/fixup_doc_links.sh "$(RELSYS_HTMLDIR)"/*.html
$(V_at)$(ERL_TOP)/make/fixup_doc_links.sh "$(RELSYS_HTMLDIR)"/*.html

release_chunks_spec: chunks
ifneq ($(CHUNK_FILES),)
Expand Down
14 changes: 12 additions & 2 deletions make/fixup_doc_links.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@

APP_VSNS=$(head -1 ${ERL_TOP}/otp_versions.table | awk -F: '{print $2}' | sed 's:#::g')

FIXUP="-e s:system/doc/html:doc/system:g"
FIXUP="-e s:lib/../::g"

if [ $(basename $(dirname "$1")) = "system" ]; then
ADJUST_PATH="../"
fi

FIXUP="${FIXUP} -e s:${ADJUST_PATH}system/doc/html:doc/system:g"

for APP_VSN in ${APP_VSNS}; do
APP=$(echo ${APP_VSN} | awk -F- '{print $1}')
FIXUP="${FIXUP} -e s:lib/${APP}/doc/html:lib/${APP_VSN}/doc/html:g"
if [ $APP = "erts" ]; then
FIXUP="${FIXUP} -e s:${ADJUST_PATH}${APP}/doc/html/:${APP_VSN}/doc/html/:g"
else
FIXUP="${FIXUP} -e s:${ADJUST_PATH}lib/${APP}/doc/html/:lib/${APP_VSN}/doc/html/:g"
fi
done

set -x
Expand Down
7 changes: 4 additions & 3 deletions scripts/otp_check_html_links.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule Anchors do
:ok
end
def maybe_warn(file, target, :false, suggestion) do
if not String.contains?(target,"jinterface/doc/html/assets/java") do
if not String.contains?(target,"doc/html/assets/java") do
if suggestion do
IO.puts("#{ file }: could not find #{ target }, should it be ##{ suggestion }?")
else
Expand Down Expand Up @@ -61,7 +61,7 @@ defmodule Anchors do
end

def validate_hrefs(file, document, anchors) do
if String.contains?(file,"jinterface/doc/html/assets/java") do
if String.contains?(file,"doc/html/assets/java") do
:ok
else
for {_, attr, _} <- Floki.find(document, "a[href]") do
Expand All @@ -76,8 +76,9 @@ end
patterns =
case System.argv do
[] -> ["doc/",
"doc/system/",
"lib/*/doc/html/",
"erts/doc/html/",
"erts*/doc/html/",
"system/doc/html/"]
patterns -> patterns
end
Expand Down

0 comments on commit 0c7b28b

Please sign in to comment.