Improve doc generation
- Downloads all the mdn documentation in parallel - Enables the `--silent` flag for curl - Aliases the docs mix task to run update_mdn_docs first
This commit is contained in:
parent
34203fcb0d
commit
fb5147ff97
2 changed files with 24 additions and 15 deletions
|
@ -7,23 +7,26 @@ defmodule Mix.Tasks.UpdateMdnDocs do
|
||||||
@shortdoc "Update the MDN documentation"
|
@shortdoc "Update the MDN documentation"
|
||||||
def run(_) do
|
def run(_) do
|
||||||
(Dsl.Tags.nonvoid_elements() ++ Dsl.Tags.void_elements())
|
(Dsl.Tags.nonvoid_elements() ++ Dsl.Tags.void_elements())
|
||||||
|> Enum.each(fn el ->
|
|> Enum.map(fn el ->
|
||||||
el = to_string(el)
|
Task.async(fn ->
|
||||||
|
el = to_string(el)
|
||||||
|
|
||||||
page =
|
page =
|
||||||
if Enum.any?(["h1", "h2", "h3", "h4", "h5", "h6"], &(&1 == el)) do
|
if Enum.any?(["h1", "h2", "h3", "h4", "h5", "h6"], &(&1 == el)) do
|
||||||
"Heading_Elements"
|
"Heading_Elements"
|
||||||
else
|
else
|
||||||
el
|
el
|
||||||
end
|
end
|
||||||
|
|
||||||
{doc, 0} = System.cmd("curl", [@baseurl <> page <> @params])
|
{doc, 0} = System.cmd("curl", ["--silent", @baseurl <> page <> @params])
|
||||||
File.mkdir_p!("./tmp/docs/")
|
File.mkdir_p!("./tmp/docs/")
|
||||||
|
|
||||||
path = "./tmp/docs/" <> el <> ".txt"
|
path = "./tmp/docs/" <> el <> ".txt"
|
||||||
doc = HtmlSanitizeEx.strip_tags(doc)
|
doc = HtmlSanitizeEx.strip_tags(doc)
|
||||||
|
|
||||||
File.write!(path, doc)
|
File.write!(path, doc)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|> Enum.each(&Task.await/1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
10
mix.exs
10
mix.exs
|
@ -4,12 +4,13 @@ defmodule Dsl.MixProject do
|
||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :dsl,
|
app: :dsl,
|
||||||
|
name: "Dsl",
|
||||||
version: "0.1.0",
|
version: "0.1.0",
|
||||||
elixirc_paths: elixirc_paths(Mix.env()),
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
elixir: "~> 1.7",
|
elixir: "~> 1.7",
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
deps: deps(),
|
deps: deps(),
|
||||||
name: "Dsl",
|
aliases: aliases(),
|
||||||
source_url: "https://github.com/mhanberg/dsl",
|
source_url: "https://github.com/mhanberg/dsl",
|
||||||
docs: [
|
docs: [
|
||||||
main: "Dsl",
|
main: "Dsl",
|
||||||
|
@ -32,8 +33,13 @@ defmodule Dsl.MixProject do
|
||||||
extra_applications: [:logger]
|
extra_applications: [:logger]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp aliases do
|
||||||
|
[
|
||||||
|
docs: ["update_mdn_docs", "docs"]
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
# Run "mix help deps" to learn about dependencies.
|
|
||||||
defp deps do
|
defp deps do
|
||||||
[
|
[
|
||||||
{:phoenix_html, "~> 2.13"},
|
{:phoenix_html, "~> 2.13"},
|
||||||
|
|
Reference in a new issue