@@ -35,14 +35,25 @@ defmodule ExDoc.CLI do
3535 quiet: :boolean ,
3636 source_ref: :string ,
3737 source_url: :string ,
38- version: :boolean
38+ version: :boolean ,
39+ warnings_as_errors: :boolean
3940 ]
4041 )
4142
42- if List . keymember? ( opts , :version , 0 ) do
43- IO . puts ( "ExDoc v#{ ExDoc . version ( ) } " )
44- else
45- generate ( args , opts , generator )
43+ cond do
44+ List . keymember? ( opts , :version , 0 ) ->
45+ IO . puts ( "ExDoc v#{ ExDoc . version ( ) } " )
46+
47+ opts [ :warnings_as_errors ] == true and ExDoc.Utils . warned? ( ) ->
48+ IO . puts (
49+ :stderr ,
50+ "Doc generation failed due to warnings while using the --warnings-as-errors option"
51+ )
52+
53+ exit ( { :shutdown , 1 } )
54+
55+ true ->
56+ generate ( args , opts , generator )
4657 end
4758 end
4859
@@ -164,29 +175,30 @@ defmodule ExDoc.CLI do
164175 ex_doc "Project" "1.0.0" "_build/dev/lib/project/ebin" -c "docs.exs"
165176
166177 Options:
167- PROJECT Project name
168- VERSION Version number
169- BEAMS Path to compiled beam files
170- --canonical Indicate the preferred URL with rel="canonical" link element
171- -c, --config Give configuration through a file instead of a command line.
172- See "Custom config" section below for more information.
173- -f, --formatter Docs formatter to use (html or epub), default: html and epub
174- --homepage-url URL to link to for the site name
175- --language Identify the primary language of the documents, its value must be
176- a valid [BCP 47](https://tools.ietf.org/html/bcp47) language tag, default: "en"
177- -l, --logo Path to the image logo of the project (only PNG or JPEG accepted)
178- The image size will be 64x64 and copied to the assets directory
179- -m, --main The entry-point page in docs, default: "api-reference"
180- -o, --output Path to output docs, default: "doc"
181- --package Hex package name
182- --paths Prepends the given path to Erlang code path. The path might contain a glob
183- pattern but in that case, remember to quote it: --paths "_build/dev/lib/*/ebin".
184- This option can be given multiple times
185- --proglang The project's programming language, default: "elixir"
186- -q, --quiet Only output warnings and errors
187- --source-ref Branch/commit/tag used for source link inference, default: "master"
188- -u, --source-url URL to the source code
189- -v, --version Print ExDoc version
178+ PROJECT Project name.
179+ VERSION Version number.
180+ BEAMS Path to compiled beam files.
181+ --canonical Indicate the preferred URL with rel="canonical" link element.
182+ -c, --config Give configuration through a file instead of a command line.
183+ See "Custom config" section below for more information.
184+ -f, --formatter Docs formatter to use (html or epub), default: html and epub.
185+ --homepage-url URL to link to for the site name.
186+ --language Identify the primary language of the documents, its value must be
187+ a valid [BCP 47](https://tools.ietf.org/html/bcp47) language tag, default: "en".
188+ -l, --logo Path to the image logo of the project (only PNG or JPEG accepted).
189+ The image size will be 64x64 and copied to the assets directory.
190+ -m, --main The entry-point page in docs, default: "api-reference".
191+ -o, --output Path to output docs, default: "doc".
192+ --package Hex package name.
193+ --paths Prepends the given path to Erlang code path. The path might contain a glob
194+ pattern but in that case, remember to quote it: --paths "_build/dev/lib/*/ebin".
195+ This option can be given multiple times.
196+ --proglang The project's programming language, default: "elixir".
197+ -q, --quiet Only output warnings and errors.
198+ --source-ref Branch/commit/tag used for source link inference, default: "master".
199+ -u, --source-url URL to the source code.
200+ -v, --version Print ExDoc version.
201+ --warnings-as-errors Exit with non-zero status if doc generation has one or more warnings.
190202
191203 ## Custom config
192204
0 commit comments