Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions lib/ex_doc/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ defmodule ExDoc.Config do
source_url_pattern: nil,
title: nil,
version: nil,
authors: nil,
skip_undefined_reference_warnings_on: []

@type t :: %__MODULE__{
Expand Down Expand Up @@ -78,6 +79,7 @@ defmodule ExDoc.Config do
source_url_pattern: nil | String.t(),
title: nil | String.t(),
version: nil | String.t(),
authors: nil | [String.t()],
skip_undefined_reference_warnings_on: [String.t()]
}
end
3 changes: 3 additions & 0 deletions lib/ex_doc/formatter/epub/templates/content_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<dc:title><%= config.project %> - <%= config.version %></dc:title>
<dc:identifier id="project-<%= config.project %>"><%= uuid %></dc:identifier>
<dc:language><%= config.language %></dc:language>
<%= for {author, index} <- Enum.with_index(config.authors || [], 1) do %>
<dc:creator id="author<%= index %>"><%= author %></dc:creator>
<% end %>
<meta property="dcterms:modified"><%= datetime %></meta>
<%= if config.cover do %>
<meta name="cover" content="cover-image"/>
Expand Down
3 changes: 3 additions & 0 deletions lib/ex_doc/formatter/html/templates/head_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v<%= ExDoc.version %>">
<meta name="project" content="<%= config.project %> v<%= config.version%>">
<%= if config.authors do %>
<meta name="author" content="<%= Enum.join(config.authors, ", ") %>">
<% end %>
<title><%= page.title %> — <%= config.project %> v<%= config.version %></title>
<link rel="stylesheet" href="<%= asset_rev config.output, "dist/html*.css" %>" />
<%= if config.canonical do %>
Expand Down
2 changes: 2 additions & 0 deletions lib/mix/tasks/docs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ defmodule Mix.Tasks.Docs do
the "assets" directory in the output path under the name "cover" and the
appropriate extension. This option has no effect when using the "html" formatter.

* `:authors` - List of authors for the generated docs or epub.

* `:main` - Main page of the documentation. It may be a module or a
generated page, like "Plug" or "api-reference"; default: "api-reference".

Expand Down
8 changes: 8 additions & 0 deletions test/ex_doc/formatter/epub_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ defmodule ExDoc.Formatter.EPUBTest do
assert content =~ ~r{<html.*lang="fr".*xmlns:epub="http://www.idpf.org/2007/ops">}ms
end

test "allows to set the authors of the book" do
generate_docs_and_unzip(doc_config(authors: ["John Doe", "Jane Doe"]))

content = File.read!("#{output_dir()}/OEBPS/content.opf")
assert content =~ ~r{<dc:creator id="author1">John Doe</dc:creator>}
assert content =~ ~r{<dc:creator id="author2">Jane Doe</dc:creator>}
end

test "raises when assets are invalid" do
File.mkdir_p!("test/tmp/epub_assets/hello")
File.touch!("test/tmp/epub_assets/hello/world.pdf")
Expand Down
7 changes: 7 additions & 0 deletions test/ex_doc/formatter/html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ defmodule ExDoc.Formatter.HTMLTest do
refute content_module =~ re[:index][:refresh]
end

test "allows to set the authors of the document" do
generate_docs(doc_config(authors: ["John Doe", "Jane Doe"]))
content_index = File.read!("#{output_dir()}/api-reference.html")

assert content_index =~ ~r{<meta name="author" content="John Doe, Jane Doe">}
end

test "generates in default directory with redirect index.html file" do
generate_docs(doc_config())

Expand Down