Current section
Files
Jump to
Current section
Files
lib/mix/tasks/docs.override.ex
defmodule Mix.Tasks.Docs.Override do
use Mix.Task
@moduledoc ~S"""
Overrides Mix.Tasks.Doc to include the screenshot in generated docs assets
"""
@docs_dir "./doc"
@img_file "screenshot.png"
@doc false
def run(args, config \\ Mix.Project.config()) do
docs_dir = Path.expand(@docs_dir)
Kernel.apply(Mix.Tasks.Docs, :run, [args, config])
if File.exists?(@docs_dir) do
content = File.read!(Path.expand(@img_file))
out_path = Path.join(docs_dir, @img_file)
File.write!(out_path, content)
end
end
end