Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible error when deprecating binaries path for assets #1924

Closed
garazdawi opened this issue Jun 19, 2024 · 4 comments
Closed

Possible error when deprecating binaries path for assets #1924

garazdawi opened this issue Jun 19, 2024 · 4 comments

Comments

@garazdawi
Copy link
Contributor

Before f4a46cb it was possible to have hidden files in the asset folder without them being included in the build. For instance we had a .gitignore file in the assets folder.

With f4a46cb it is no longer possible and we get this error:

** (RuntimeError) asset with extension "" is not supported by EPUB format
    (ex_doc 0.34.0) lib/ex_doc/formatter/epub/templates.ex:138: ExDoc.Formatter.EPUB.Templates.media_type/1
    (ex_doc 0.34.0) lib/ex_doc/formatter/epub/templates/content_template.eex:27: anonymous fn/1 in ExDoc.Formatter.EPUB.Templates.content_template/5
    (elixir 1.17.0-dev) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
    (elixir 1.17.0-dev) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
    (ex_doc 0.34.0) lib/ex_doc/formatter/epub/templates/content_template.eex:26: ExDoc.Formatter.EPUB.Templates.content_template/5
    (ex_doc 0.34.0) lib/ex_doc/formatter/epub.ex:85: ExDoc.Formatter.EPUB.generate_content/5
    (ex_doc 0.34.0) lib/ex_doc/formatter/epub.ex:41: ExDoc.Formatter.EPUB.run/3
    (ex_doc 0.34.0) lib/ex_doc/cli.ex:69: anonymous fn/6 in ExDoc.CLI.generate/3

It is not a big problem for us to remove the .gitignore, just opening this issue to see if the original behaviour was intentional or not.

@josevalim
Copy link
Member

We should fix this I think. I wonder if we should do it by explicitly discarding .gitignore or by discarding everything starting with .. Thoughts?

@garazdawi
Copy link
Contributor Author

Since . indicates hidden on Unix I think that we should discard all those, which I think is what the old implementation did.

@josevalim
Copy link
Member

I decided to keep all assets because we do a recursive traversal and skipping dot files in there would require adding a feature to Elixir first. Which basically means the empty .gitignore file will be part of the assets. If that's an issue, let me know, I will be glad to revisit it. :)

@garazdawi
Copy link
Contributor Author

Sounds good to me. I did an attempt att solving this and ended up with this hack:

is_binary(dir_or_files) and File.dir?(dir_or_files) ->
  dir_or_files
  |> File.cp_r!(target_dir)
  |> Enum.filter(fn path ->
    ## Remove any file that starts with a .
    if path |> Path.basename() |> String.first() != "." do
      File.rm!(path)
      false
    else
      true
    end
  end)
  |> Enum.map(&Path.relative_to(&1, output))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants