diff --git a/assets/less/content/footer.less b/assets/less/content/footer.less index 9957cc861..026ba27a2 100644 --- a/assets/less/content/footer.less +++ b/assets/less/content/footer.less @@ -20,6 +20,10 @@ .linkUnderlines(@mediumGray) } + .footer-hex-package { + margin-right: 4px; + } + a { color: @mediumGray; .linkUnderlines(@mediumGray) diff --git a/lib/ex_doc/cli.ex b/lib/ex_doc/cli.ex index 86479220c..cbf4232ae 100644 --- a/lib/ex_doc/cli.ex +++ b/lib/ex_doc/cli.ex @@ -24,6 +24,7 @@ defmodule ExDoc.CLI do switches: [ language: :string, paths: :keep, + package: :string, proglang: :string, source_ref: :string, version: :boolean @@ -156,6 +157,7 @@ defmodule ExDoc.CLI do -l, --logo Path to the image logo of the project (only PNG or JPEG accepted) The image size will be 64x64 and copied to the assets directory -m, --main The entry-point page in docs, default: "api-reference" + --package Hex package name --source-ref Branch/commit/tag used for source link inference, default: "master" -r, --source-root Path to the source code root, used for generating links, default: "." -u, --source-url URL to the source code diff --git a/lib/ex_doc/config.ex b/lib/ex_doc/config.ex index 2cb2f540d..9102c04df 100644 --- a/lib/ex_doc/config.ex +++ b/lib/ex_doc/config.ex @@ -43,7 +43,8 @@ defmodule ExDoc.Config do title: nil, version: nil, authors: nil, - skip_undefined_reference_warnings_on: [] + skip_undefined_reference_warnings_on: [], + package: nil @type t :: %__MODULE__{ apps: [atom()], @@ -78,6 +79,7 @@ defmodule ExDoc.Config do title: nil | String.t(), version: nil | String.t(), authors: nil | [String.t()], - skip_undefined_reference_warnings_on: [String.t()] + skip_undefined_reference_warnings_on: [String.t()], + package: :atom | nil } end diff --git a/lib/ex_doc/formatter/html.ex b/lib/ex_doc/formatter/html.ex index 223380c80..5bf6c2da6 100644 --- a/lib/ex_doc/formatter/html.ex +++ b/lib/ex_doc/formatter/html.ex @@ -205,8 +205,8 @@ defmodule ExDoc.Formatter.HTML do defp generate_extras(nodes_map, extras, config) do extras |> with_prev_next() - |> Enum.map(fn {%{id: id, title: title, content: content}, prev, next} -> - filename = "#{id}.html" + |> Enum.map(fn {node, prev, next} -> + filename = "#{node.id}.html" output = "#{config.output}/#{filename}" config = set_canonical_url(config, filename) @@ -215,7 +215,7 @@ defmodule ExDoc.Formatter.HTML do next: next && %{path: "#{next.id}.html", title: next.title} } - html = Templates.extra_template(config, title, nodes_map, content, refs) + html = Templates.extra_template(config, node, nodes_map, refs) if File.regular?(output) do IO.puts(:stderr, "warning: file #{Path.relative_to_cwd(output)} already exists") @@ -338,7 +338,7 @@ defmodule ExDoc.Formatter.HTML do group = GroupMatcher.match_extra(groups, input) title = title || extract_title(html_content) || filename_to_title(input) - %{id: id, title: title, group: group, content: html_content} + %{id: id, title: title, group: group, content: html_content, source_path: input} end defp extension_name(input) do diff --git a/lib/ex_doc/formatter/html/templates.ex b/lib/ex_doc/formatter/html/templates.ex index 943edac9c..87a89e317 100644 --- a/lib/ex_doc/formatter/html/templates.ex +++ b/lib/ex_doc/formatter/html/templates.ex @@ -267,13 +267,13 @@ defmodule ExDoc.Formatter.HTML.Templates do templates = [ detail_template: [:node, :_module], - footer_template: [:config], + footer_template: [:config, :node], head_template: [:config, :page], module_template: [:config, :module, :summary, :nodes_map], not_found_template: [:config, :nodes_map], api_reference_entry_template: [:module_node], api_reference_template: [:config, :nodes_map], - extra_template: [:config, :title, :nodes_map, :content, :refs], + extra_template: [:config, :node, :nodes_map, :refs], search_template: [:config, :nodes_map], sidebar_template: [:config, :nodes_map], summary_template: [:name, :nodes], diff --git a/lib/ex_doc/formatter/html/templates/extra_template.eex b/lib/ex_doc/formatter/html/templates/extra_template.eex index 3264e84f0..4d3dd52a5 100644 --- a/lib/ex_doc/formatter/html/templates/extra_template.eex +++ b/lib/ex_doc/formatter/html/templates/extra_template.eex @@ -1,6 +1,6 @@ -<%= head_template(config, %{title: title, type: :extra}) %> +<%= head_template(config, %{title: node.title, type: :extra}) %> <%= sidebar_template(config, nodes_map) %> -<%= link_headings(content) %> +<%= link_headings(node.content) %> <%= bottom_actions_template(refs) %> -<%= footer_template(config) %> +<%= footer_template(config, node) %> diff --git a/lib/ex_doc/formatter/html/templates/footer_template.eex b/lib/ex_doc/formatter/html/templates/footer_template.eex index 4ef6ab81d..5948d00ca 100644 --- a/lib/ex_doc/formatter/html/templates/footer_template.eex +++ b/lib/ex_doc/formatter/html/templates/footer_template.eex @@ -1,4 +1,16 @@