-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow listing outside URLs in extras #2103
Open
sorentwo
wants to merge
6
commits into
elixir-lang:main
Choose a base branch
from
sorentwo:allow-extra-urls
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
639afcc
Allow listing outside URLs in extras
sorentwo 7d56189
Omit url extras when generating html paths
sorentwo c18894d
Skip generating files for extras in epub formatter
sorentwo b873af5
Prune unnecessary map fields for url extras
sorentwo a9be4ab
Document the new :url option in mix docs
sorentwo 861d451
Merge branch 'main' into allow-extra-urls
sorentwo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
formatters/html/dist/html-5PS32TPG.js → formatters/html/dist/html-AG646WP7.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,36 +18,8 @@ defmodule ExDoc.Formatter.HTML.SearchData do | |
["searchData=" | ExDoc.Utils.to_json(data)] | ||
end | ||
|
||
defp extra(map) do | ||
if custom_search_data = map[:search_data] do | ||
extra_search_data(map, custom_search_data) | ||
else | ||
Comment on lines
-22
to
-24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a clause for this rather than a conditional in the function body. |
||
{intro, sections} = extract_sections_from_markdown(map.source) | ||
|
||
intro_json_item = | ||
encode( | ||
"#{map.id}.html", | ||
map.title, | ||
:extras, | ||
intro | ||
) | ||
|
||
section_json_items = | ||
for {header, body} <- sections do | ||
encode( | ||
"#{map.id}.html##{Utils.text_to_id(header)}", | ||
header <> " - #{map.title}", | ||
:extras, | ||
body | ||
) | ||
end | ||
|
||
[intro_json_item | section_json_items] | ||
end | ||
end | ||
|
||
defp extra_search_data(map, custom_search_data) do | ||
Enum.map(custom_search_data, fn item -> | ||
defp extra(%{search_data: search_data} = map) when is_list(search_data) do | ||
Enum.map(search_data, fn item -> | ||
link = | ||
if item.anchor === "" do | ||
"#{map.id}.html" | ||
|
@@ -59,6 +31,34 @@ defmodule ExDoc.Formatter.HTML.SearchData do | |
end) | ||
end | ||
|
||
defp extra(%{url: url} = map) do | ||
[encode("#{map.id}", map.title, :extras, url)] | ||
end | ||
|
||
defp extra(map) do | ||
{intro, sections} = extract_sections_from_markdown(map.source) | ||
|
||
intro_json_item = | ||
encode( | ||
"#{map.id}.html", | ||
map.title, | ||
:extras, | ||
intro | ||
) | ||
|
||
section_json_items = | ||
for {header, body} <- sections do | ||
encode( | ||
"#{map.id}.html##{Utils.text_to_id(header)}", | ||
header <> " - #{map.title}", | ||
:extras, | ||
body | ||
) | ||
end | ||
|
||
[intro_json_item | section_json_items] | ||
end | ||
|
||
defp module(%ExDoc.ModuleNode{} = node) do | ||
{intro, sections} = extract_sections(node.doc_format, node) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is purely for pattern matching to flatten out
build_extra/5
. The alternative was a cond inbuild_extra/5
, but this seemed a little clearer.