Skip to content
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

add support for admonition text blocks #1400

Merged
merged 19 commits into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/fonts/icomoon.eot
Binary file not shown.
3 changes: 3 additions & 0 deletions assets/fonts/icomoon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/fonts/icomoon.ttf
Binary file not shown.
Binary file modified assets/fonts/icomoon.woff
Binary file not shown.
52 changes: 46 additions & 6 deletions assets/less/content/general.less
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,58 @@ a.view-source {

blockquote {
font-style: italic;
margin: .5em 0;
padding: .25em 1.5em;
border-left: 3px solid @gray;
display: inline-block;
position: relative;
margin: 1.5625em 0;
padding: 0 1.2rem;
font-size: 1.28rem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
font-size: 1.28rem;

I am thinking we should let the default font-size do its job so we keep everything consistent. WDYT? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking we should let the default font-size do its job so we keep everything consistent. WDYT? :)

Maybe I am wrong but does rem not just reflect a bigger font relative to the default font size, or did you mean that this style should have the default font size?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t notice the rem but yeah, what I mean is to keep it as is. :)

overflow: auto;
background-color: #f6f6f6;
border-radius: 3px;

*:first-child {
milmazz marked this conversation as resolved.
Show resolved Hide resolved
padding-top: 0;
margin-top: 0;
margin: 0 -1.2rem;
padding: 0.8rem 1.2rem 0.8rem 4rem;
milmazz marked this conversation as resolved.
Show resolved Hide resolved
font-weight: 700;

&::before {
position: absolute;
left: 1.2rem;
font-size: 2rem;
milmazz marked this conversation as resolved.
Show resolved Hide resolved

.icon-elem
}

&.warning {
background-color: rgba(255, 145, 0, 0.1);

&::before {
color: #ff9100;
content: "\ea07";
}
}

&.info {
background-color: rgba(0, 184, 212, 0.1);

&::before {
color: #00b8d4;
content: "\ea0c";
}
}

&.error {
background-color: rgba(255, 23, 68, 0.1);

&::before {
color: #ff1744;
content: "\e999";
}
}
}

*:last-child {
milmazz marked this conversation as resolved.
Show resolved Hide resolved
padding-bottom: 0;
padding-bottom: 1em;
margin-bottom: 0;
}
}
Expand Down
12 changes: 12 additions & 0 deletions assets/less/icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
.icon-code:before {
content: "\f121";
}
.icon-warning:before {
content: "\ea07";
}
.icon-info:before {
content: "\ea0c";
}
.icon-error:before {
content: "\e999";
}

@icon-link: "\e005";
@icon-search: "\e036";
Expand All @@ -61,3 +70,6 @@
@icon-goto: "\e968";
@icon-angle-right: "\f105";
@icon-code: "\f121";
@icon-warning: "\ea07";
@icon-info: "\ea0c";
@icon-error: "\e999";

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions formatters/html/dist/elixir-37545fd2f35b96531434.css

This file was deleted.

2 changes: 2 additions & 0 deletions formatters/html/dist/elixir-debba3358a19ca73ec69.css

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions formatters/html/dist/erlang-951161c89561e05735a5.css

This file was deleted.

2 changes: 2 additions & 0 deletions formatters/html/dist/erlang-ce3940886ae404f128c2.css

Large diffs are not rendered by default.

Binary file modified formatters/html/fonts/icomoon.eot
Binary file not shown.
3 changes: 3 additions & 0 deletions formatters/html/fonts/icomoon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified formatters/html/fonts/icomoon.ttf
Binary file not shown.
Binary file modified formatters/html/fonts/icomoon.woff
Binary file not shown.
23 changes: 21 additions & 2 deletions lib/ex_doc/formatter/html/templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,30 @@ defmodule ExDoc.Formatter.HTML.Templates do
|> elem(0)
end

@class_regex ~r/class="([^"]+)/
@class_separator " "
defp link_heading(match, _tag, _title, "", _prefix), do: match

defp link_heading(_match, tag, title, id, prefix) do
defp link_heading(match, tag, title, id, prefix) do
josevalim marked this conversation as resolved.
Show resolved Hide resolved
section_header_class_name = "section-heading"

class_attribute =
case Regex.run(@class_regex, match, capture: :all_but_first) do
nil ->
section_header_class_name

[previous_classes] ->
# Let's make sure that the `section_header_class_name` is not already
# included in the previous classes for the header
previous_classes
|> String.split(@class_separator)
|> Enum.reject(&(&1 == section_header_class_name))
|> Enum.join(@class_separator)
|> Kernel.<>(" #{section_header_class_name}")
end
josevalim marked this conversation as resolved.
Show resolved Hide resolved

"""
<#{tag} id="#{prefix}#{id}" class="section-heading">
<#{tag} id="#{prefix}#{id}" class="#{class_attribute}">
<a href="##{prefix}#{id}" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
#{title}
</#{tag}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<%= if nodes_map.modules != [] do %>
<section class="details-list">
<h2 id="modules" class="section-heading">Modules</h2>
milmazz marked this conversation as resolved.
Show resolved Hide resolved
<h2 id="modules">Modules</h2>
<div class="summary">
<%= for module_node <- Enum.sort_by(nodes_map.modules, & &1.id) do
api_reference_entry_template(module_node)
Expand All @@ -15,7 +15,7 @@

<%= if nodes_map.tasks != [] do %>
<section class="details-list">
<h2 id="tasks" class="section-heading">Mix Tasks</h2>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEWER: Not needed, this is injected by ExDoc.Formatter.HTML.Templates.link_heading/5

<h2 id="tasks">Mix Tasks</h2>
<div class="summary">
<%= for task_node <- nodes_map.tasks do
api_reference_entry_template(task_node)
Expand Down