-
Notifications
You must be signed in to change notification settings - Fork 340
Allow listing outside URLs in extras #2103
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
base: main
Are you sure you want to change the base?
Conversation
This makes it possible to delcare URLs as extras and have them listed as links in the sidebar. For example, to set a "Wikipedia" url: ```elixir extras: [ "Wikipedia": [url: "https://wikipedia.com"] ] ``` Closes elixir-lang#2084
68d3c53
to
639afcc
Compare
if custom_search_data = map[:search_data] do | ||
extra_search_data(map, custom_search_data) | ||
else |
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.
Added a clause for this rather than a conditional in the function body.
For the |
Suggestions applied, changes made , and residual TODO items addressed. This is all set! |
@@ -112,6 +112,24 @@ defmodule ExDoc.Formatter.HTMLTest do | |||
assert LazyHTML.text(bar_content["h1"]) == "README bar" | |||
end | |||
|
|||
test "extras defined as external urls", %{tmp_dir: tmp_dir} = context do | |||
config = |
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.
I think we should add a test that shows grouping work. Imagine you want all URLs in a section in the sidebar called Important Links. The Template.sidebar_extras
kinda implies URLs work with groups but we need to be sure it works "end to end".
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.
It seems groups expect the filename but there is none here, so we probably have to pass the filename or the url (and update its docs accordingly).
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.
Grouping does work based on the input name, but it doesn't consider the URL. For example, with the extra [Elixir: [url: "https://elixir-lang.org"]]
this will match on "Elixir", but it doesn't consider the url value at all.
input = to_string(input)
title = input_options[:title] || input
group = GroupMatcher.match_extra(groups, input)
That's a little different than how regular grouping works because the input lacks path information for easy grouping.
I've opted to expand GroupMatcher.match_extra
to be url/path aware, so the pattern applies to either the title or url.
@@ -59,6 +59,7 @@ export function initialize () { | |||
const items = [] | |||
const hasHeaders = Array.isArray(node.headers) | |||
const translate = hasHeaders ? undefined : 'no' | |||
const href = node?.url || `${node.id}.html` |
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.
Should we add an icon, such as this one, for URLs?
If so, you can upload this bundle to remixicon.com, add external link, and get the new font back: https://github.com/elixir-lang/ex_doc/blob/main/assets/fonts/RemixIconCollection.remixicon
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.
@josevalim Suggestions and changes made, ready for another pass |
This makes it possible to delcare URLs as extras and have them listed as links in the sidebar. For example, to set a "Wikipedia" url:
This is currently light on some validations. I'll expand the tests and URI validation if the approach is improved.
Validate theurl
value is an actual URIExpand formatter testsurl
optionsCloses #2084