blackode

blackode

How to add images in hex package documentation with exdoc

Hi,
I generated Docs using the exdoc module.
The index.html is showing the images when I checked offline,but when I publish to the
HEX Package Manager images are not showing.
is anything to add more ?
if not possible with exdoc please specify an alternative.

Screenshot

Thanks in Advance :bouquet:

Marked As Solved

ericmj

ericmj

Elixir Core Team

You need to put the images inside the doc/ directory. Hex only pushes things inside that directory to hexdocs [1], we do not traverse the markdown to resolve links to resources anywhere on your filesystem. You might also want to copy the images inside an alias [2] on the docs task that runs after ex_doc to ensure that ex_doc does not overwrite the directory:

defp aliases do
  [docs: ["docs", &copy_images/1]]
end

defp copy_images(_) do
  File.cp! ...
end

[1] Hex v2.5.0 — Documentation
[2] Mix — Mix v1.20.2

10
Post #5

Last Post!

blackode

blackode

Thanks for the quick response. The above one only works to copy contents of one file to another.After looking into more with your suggestions I found the follwing code snippets which copy the contents of source to destination in the official docs

defp copy_images(_) do
   File.cp_r "source", "destination", fn(source, destination) ->
   IO.gets("Overwriting #{destination} by #{source}. Type y to confirm. ") == "y\n"
   end
end

That really solved the problem. Thanks for that amazing stuff. Now Images are shown in the docs.
The Printex Documentation
:bouquet: :bouquet: Once again Thanks a lot.

Where Next?

Popular in Questions Top

ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement