Conversation
|
@josevalim ping |
50a8c11 to
3763888
Compare
fd3ff34 to
d0c72da
Compare
a9d91ba to
a587b99
Compare
|
@josevalim Ping, any review is greatly appreciated. At this stage, I think that this new feature is in beta and if you think it's right moment we can merge into master. Thanks in advance 👌 |
|
Thank you @milmazz! I need to prepare for my keynote and release Elixir v1.1. So let's push ExDoc 0.10 first and then I will focus on this with you. ❤️ |
|
No problem @josevalim, in the meantime I'll try to improve the CSS styles, I hope that everything goes well on the ElixirConf ❤️ |
|
Would it make any sense to extract some of the epub generation to a general-purpose epub lib? |
|
We haven't even landed epub support yet. Once we do and once it works, we can possibly start a discussion about extracting it. :D |
|
That's completely fair. I was mostly thinking that this could make this PR smaller and also give @milmazz something to do until this is back in focus :D @josevalim, best of luck with the keynote! Wish I could be there :) |
|
@henrik In the meantime you can review the code if you want, any feedback is more than welcome :) I'll try to update this PR as soon as possible. |
lib/ex_doc/formatter/epub.ex
Outdated
There was a problem hiding this comment.
Here is possible, I'm new in elixir, only return :zip.create... eg:
defp generate_epub(output, config) do
output = Path.expand(output)
target_path =
"#{output}/#{config.project}-v#{config.version}.epub"
|> String.to_char_list
:zip.create(target_path,
files_to_add(output),
compress: ['.css', '.html', '.ncx', '.opf',
'.jpg', '.png', '.xml'])
endOn line 42 you are doing the check if is :ok
There was a problem hiding this comment.
That's a common Elixir practice. Somtimes it is preferable to match on the result when we call it so we get the proper cause on errors: http://blog.plataformatec.com.br/2014/09/writing-assertive-code-with-elixir/
There was a problem hiding this comment.
but isn't the last line "{:ok, zip_path}" unnecessary? since that's what the previous line returns
There was a problem hiding this comment.
Yes, the last line can be deleted, I'll fix that!
1180ac6 to
473bbed
Compare
|
@josevalim This weekend I finally resume working on this feature, I would like your review about this. If you approve this feature in |
|
@josevalim ping? |
| defp extra_title(path), do: path |> String.upcase |> Path.basename(".MD") | ||
|
|
||
| templates = [ | ||
| content_template: {[:config, :nodes, :uuid, :datetime], @content_template_doc}, |
There was a problem hiding this comment.
Since you want to attach docs, I would rather call EEx.function_from_file one by one instead of building this whole list. :)
|
@milmazz this looks great to me! I have added only one tiny comment. The other thing that is missing is the documentation aspect. How to use EPUB? I would add some information to the README as well to the Another point of concern is code duplication between the formatters but I haven't taken a deep look yet. What do you think? Were you able to re-use most of the code? Is there any area you would like to avoid the duplication bit? In any case, feel free to merge it to master any time you want. |
cb57073 to
890d339
Compare
|
|
||
| gulp.task('epub-javascript', ['buildHighlight'], function () { | ||
| return javascript({src: 'assets/js/epub.js', dest: distPath.epub}, function () {}); | ||
| }) |
There was a problem hiding this comment.
@dignifiedquire Do you think this is a good way to reuse this task without affecting the current behavior?
There was a problem hiding this comment.
It is fine to affect the current behaviour though since this is an internal tool.
|
@josevalim I just add more improvements, this is the current status: About your suggestions:
You're right, I'll add more information about this new feature asap.
Yeah, I know, I tried to avoid the code duplication between both formats as much as possible. Actually, I use many functions from the @elixir-lang/exdoc Any other suggestion is more than welcome. |
|
It looks beautiful. I should do another full review pass today or tomorrow and add any pending feedback. |
assets/README.md
Outdated
| Using the flag `--type production` will result in minified JavaScript and CSS | ||
| bundles. | ||
|
|
||
| ### `epub-build` |
There was a problem hiding this comment.
Would it possible to have build do both epub and html builds? This way we should still keep build but we can then use the epub-build and html-build only if I want explicitly too.
assets/README.md
Outdated
|
|
||
| Build the JavaScript in `js` into a bundled file using [webpack]. | ||
|
|
||
| ### `epub-javascript` |
There was a problem hiding this comment.
Should we normalize all names to be FORMATTER-TASK? So we would have epub-javascript and html-javascript. Otherwise I am afraid it will be confusing. What do you think?
There was a problem hiding this comment.
I agree with your suggestion.
| <%= for node <- nodes do %> | ||
| <item id="<%= node.id %>" href="<%= node.id %>.xhtml" media-type="application/xhtml+xml" properties="scripted"/> | ||
| <% end %> | ||
| <% alias ExDoc.Formatter.HTML.Templates, as: T %> |
There was a problem hiding this comment.
We should probably move those aliases to the top of the template OR to the module that defines the templates.
There was a problem hiding this comment.
Better to move the alias to the module that uses the templates, that way we avoid a blank line at the beginning of this XML file (epubchecker emits a warning for this).
|
@milmazz i have added a couple more comments, then we are good to go! |
|
@milmazz I did another review and it looks amazing! ❤️ The only thing left I can think of is to add support for the |
|
@josevalim Done! 🎉 $ mix docs --formatter epub
Compiling 1 file (.ex)
Docs successfully generated.
View them at '/Users/milmazz/Development/elixir-lang/ex_doc/doc/ex_doc-v0.13.2.epub'.
$ mix docs -f epub
Docs successfully generated.
View them at '/Users/milmazz/Development/elixir-lang/ex_doc/doc/ex_doc-v0.13.2.epub'. |
|
@milmazz please fix the functions you created in https://github.com/elixir-lang/ex_doc/blob/master/gulpfile.js#L202 ( var javascript = function (options) {
return gulp.src(options.src)
.pipe(webpack(isProduction ? config.production : config.development))
.pipe($.if(isProduction, $.uglify()))
.pipe($.if(isProduction, $.rev()))
.pipe($.size({title: 'js'}))
.pipe(gulp.dest(options.dest))
}otherwise |
|
@dignifiedquire Thanks for your suggestion. I already made the change, please let me know what do you think. |
|
@milmazz LGTM :) |




This is a work in progress, the idea is to know your opinion about the current progress.
Things to do:
Tasks already done:
Autolinkfrom theHTMLformatter.Some of the known bugs are the following:
WhenFix: e4e5c65ExDocis executed from the command line (../ExDoc/bin/ex_doc ... -m Kernel -f epub) I'm getting anUndefinedFunctionError(the problem is related with the newUUIDdependency), but everything runs OK viaMIX_ENV=docs mix docs -f epub, any advice?According to theFix: 0e8dab4epubchecktool themimetypefile contains a wrong type, but I don't know yet the reason for this (Am I using the:zip.createfunction correctly?). This file needs to comply with the following rulesThe other annoying error reported byFix: e680b00epubcheckis related with the ids (anchor) generated byAutolink.One way to solve this is to post-process the results from the templates, something like this:
But this to me seems like an ugly hack and maybe with this hack we can create a duplicate ID (I need to verify this, but each duplicate ID will be reported by
epubcheckas an error), but I want to reuseExDoc.Formatter.HTML.Autolinkas much as possible. Any advice?Example for Ecto:
Closes #305