将源代码输出成 epub 等格式的书籍
将源代码输出成 epub 等格式的书籍
Table of Contents
- 1. 效果
- 2. 前提
- 3. 使用
1 效果
本工具介绍 agentzh 大神的 code2ebook 项目,可以直接跳过去看英文文档,这里我更简洁的介绍使用方法,并且简单说一下遇到的问题将源代码生成 html、epub、mobi、pdf 格式的电子书,并且是有函数定义跳转的那种,就像在 ide 中
2 前提
- vim
- perl
- ctags
- calibre 一款电子书管理软件
3 使用
上面工具安装好之后
- 将代码 clone 到本地
- 将目录加入到 PATH 环境变量中
- 切换到源码目录
- 执行下面的 src2html.pl 命令
export PATH=/path/to/code2ebook:$PATH cd /path/to/your/project/ src2html.pl --tab-width 4 --color --cross-reference \ --navigator --line-numbers . 'Your Book Title'
当然,可以使用 -j 选项在多核 cpu 上面加速执行
执行完成后会生成一个 html_out/index.html 文件
使用浏览器打开就可以看具体的代码了
继续操作~
使用刚才下载安装好的 calibre 软件转换成 epub 或者其他书籍格式
/Applications/calibre.app/Contents/MacOS/ebook-convert html_out/index.html nginx-1.9.2-chinese.epub \ --output-profile ipad3 \ --no-default-epub-cover \ --title "nginx-1.9.2-chinese" --publisher 'wudanyang' \ --language en --authors 'wudanyang'
ok, 成功,看书吧
分享一下 大神注释过的 nginx 代码 生成的 epub 文件:
链接: https://pan.baidu.com/s/1jdc0x7SnnxDCB5FrnwrZ0w
提取码: wcpw
复制这段内容后打开百度网盘手机 App,操作更方便哦
===
更新时间: 2020-09-24 Thu 22:49
Emacs 28.0.50 (Org mode 9.4)
===
天行健,君子以自强不息。
地势坤,君子以厚德载物。
===