docfu 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -7
- data/README.md +14 -0
- data/lib/docfu.rb +1 -1
- data/lib/docfu/files/config.yml +17 -8
- data/lib/docfu/outputs/pdf.rb +33 -12
- data/lib/docfu/templates/book.tex +24 -23
- metadata +16 -18
data/Gemfile
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
5
|
|
6
|
-
gem "mixlib-cli", "~> 1.
|
6
|
+
gem "mixlib-cli", "~> 1.3.0"
|
7
7
|
|
8
8
|
# Add dependencies to develop your gem here.
|
9
9
|
# Include everything needed to run rake, tests, features, etc.
|
10
10
|
group :development do
|
11
|
-
gem "rspec", "~> 2.
|
12
|
-
gem "yard", "~> 0.
|
11
|
+
gem "rspec", "~> 2.13.0"
|
12
|
+
gem "yard", "~> 0.8.6.1"
|
13
13
|
gem "cucumber", ">= 0"
|
14
|
-
gem "bundler", "~> 1.
|
15
|
-
gem "jeweler", "
|
16
|
-
gem (RUBY_VERSION
|
14
|
+
gem "bundler", "~> 1.3.5"
|
15
|
+
gem "jeweler", :git => "https://github.com/aia/jeweler.git", :branch => 'simplecov'
|
16
|
+
gem (RUBY_VERSION.gsub('.', '').to_i >= 190 ? "simplecov" : "rcov"), ">= 0"
|
17
17
|
end
|
data/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
A document generation utility. The intention is to make writing documentation // books less lame.
|
4
4
|
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
On centos the following libraries need be installed:
|
8
|
+
|
9
|
+
texlive-latex texlive-xetex liberation pandoc
|
10
|
+
liberation-fonts-mono-fonts liberation-fonts-serif-fonts
|
11
|
+
liberation-fonts-common
|
12
|
+
|
5
13
|
## Contributing to docfu
|
6
14
|
|
7
15
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
@@ -12,6 +20,12 @@ A document generation utility. The intention is to make writing documentation //
|
|
12
20
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
21
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
22
|
|
23
|
+
## Special Thanks
|
24
|
+
|
25
|
+
This library was heavily based from (with permission) the skeleton that Scott Chacon used for the book Pro Git.
|
26
|
+
|
27
|
+
If you haven't checked it out, you should pick up a [copy](http://www.amazon.com/Pro-Git-Scott-Chacon/dp/1430218339)!
|
28
|
+
|
15
29
|
## Copyright
|
16
30
|
|
17
31
|
Copyright (c) 2012 Josh Toft. See LICENSE.txt for
|
data/lib/docfu.rb
CHANGED
data/lib/docfu/files/config.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
default:
|
2
|
-
font:
|
2
|
+
font: Helvetica
|
3
3
|
bold: "{* Bold}"
|
4
|
-
mono:
|
4
|
+
mono: Andale Mono
|
5
5
|
prechap: "Chapter "
|
6
6
|
postchap: ""
|
7
7
|
presect: "Section "
|
@@ -12,7 +12,6 @@ default:
|
|
12
12
|
fig: "Figure "
|
13
13
|
tab: "Table "
|
14
14
|
indent: "\\qquad"
|
15
|
-
thanks: ""
|
16
15
|
zh:
|
17
16
|
langrule: "\\XeTeXlinebreakskip=0em plus 0.1em minus 0.01em\n\\XeTeXlinebreakpenalty=0"
|
18
17
|
font: AR PL UMing CN
|
@@ -68,6 +67,7 @@ ru:
|
|
68
67
|
tab: "Таблица "
|
69
68
|
dql: "«"
|
70
69
|
dqr: "»"
|
70
|
+
langrule: "\\frenchspacing"
|
71
71
|
cs:
|
72
72
|
prechap: "Kapitola "
|
73
73
|
presect: "Oddíl "
|
@@ -78,15 +78,20 @@ cs:
|
|
78
78
|
fr:
|
79
79
|
prechap: "Chapitre "
|
80
80
|
presect: "Section "
|
81
|
-
fig: "
|
81
|
+
fig: "figure "
|
82
82
|
tab: "Tableau "
|
83
83
|
font: Linux Libertine
|
84
84
|
mono: Courier New
|
85
85
|
con: "Table des matières"
|
86
86
|
langrule: "\\frenchspacing\\usepackage{fontspec}\n\\fontspec[Ligatures={Common}]{Linux Libertine}\n"
|
87
|
-
thanks: ""
|
88
87
|
dql: "«\\,"
|
89
88
|
dqr: "\\,»"
|
89
|
+
es:
|
90
|
+
prechap: "Capítulo "
|
91
|
+
presect: "Sección "
|
92
|
+
fig: "Figura "
|
93
|
+
tab: "Tabla "
|
94
|
+
con: "Contenidos "
|
90
95
|
mk:
|
91
96
|
fig: "Слика"
|
92
97
|
con: "Содржина"
|
@@ -95,19 +100,23 @@ mk:
|
|
95
100
|
dql: "„"
|
96
101
|
dqr: "“"
|
97
102
|
tab: "Табела"
|
103
|
+
no-nb:
|
104
|
+
dql: "«"
|
105
|
+
dqr: "»"
|
98
106
|
de:
|
99
107
|
langrule: "\\frenchspacing"
|
100
108
|
dql: "„"
|
101
109
|
dqr: "“"
|
102
110
|
ko:
|
103
111
|
langrule: "\\XeTeXlinebreakskip=0em plus 0.1em minus 0.01em\n\\XeTeXlinebreakpenalty=0"
|
104
|
-
font:
|
105
|
-
bold:
|
106
|
-
mono:
|
112
|
+
font: NanumMyeongjo
|
113
|
+
bold: "{* Bold}"
|
114
|
+
mono: NanumGothicCoding
|
107
115
|
prechap: ""
|
108
116
|
postchap: "장"
|
109
117
|
presect: ""
|
110
118
|
postsect: "절"
|
119
|
+
indent: " "
|
111
120
|
con: "목차"
|
112
121
|
fig: "그림"
|
113
122
|
tab: "표"
|
data/lib/docfu/outputs/pdf.rb
CHANGED
@@ -96,11 +96,28 @@ module Docfu
|
|
96
96
|
def pre_pandoc(string, cfg)
|
97
97
|
replace(string) do
|
98
98
|
# Pandoc discards #### subsubsections #### - this hack recovers them
|
99
|
+
s(/\#\#\#\#\# (.*?) \#\#\#\#\#/, 'PARAGRAPH: \1')
|
99
100
|
s(/\#\#\#\# (.*?) \#\#\#\#/, 'SUBSUBSECTION: \1')
|
100
101
|
|
101
102
|
# Turns URLs into clickable links
|
102
|
-
s(/\`(http:\/\/[A-Za-z0-9\/\%\&\=\-\_
|
103
|
-
s(/(\n\n)\t(http:\/\/[A-Za-z0-9\/\%\&\=\-\_
|
103
|
+
s(/\`(http:\/\/[A-Za-z0-9\/\%\&\=\-\_\\\.\(\)\#]+)\`/, '<\1>')
|
104
|
+
s(/(\n\n)\t(http:\/\/[A-Za-z0-9\/\%\&\=\-\_\\\.\(\)\#]+)\n([^\t]|\t\n)/, '\1<\2>\1')
|
105
|
+
|
106
|
+
# Match table in markdown and change them to pandoc's markdown tables
|
107
|
+
s(/(\n(\n\t([^\t\n]+)\t([^\t\n]+))+\n\n)/) do
|
108
|
+
first_col=20
|
109
|
+
t = $1.gsub(/(\n?)\n\t([^\t\n]+)\t([^\t\n]+)/) do
|
110
|
+
if $1=="\n"
|
111
|
+
# This is the header, need to add the dash line
|
112
|
+
$1 << "\n " << $2 << " "*(first_col-$2.length) << $3 <<
|
113
|
+
"\n " << "-"*18 << " " << "-"*$3.length
|
114
|
+
else
|
115
|
+
# Table row : format the first column as typewriter and align
|
116
|
+
$1 << "\n `" << $2 << "`" + " "*(first_col-$2.length-2) << $3
|
117
|
+
end
|
118
|
+
end
|
119
|
+
t << "\n"
|
120
|
+
end
|
104
121
|
|
105
122
|
# Process figures
|
106
123
|
s(/Insert\s18333fig\d+\.png\s*\n.*?\d{1,2}-\d{1,2}\. (.*)/, 'FIG: \1')
|
@@ -117,15 +134,15 @@ module Docfu
|
|
117
134
|
s(/SUBSUBSECTION: (.*)/, '\subsubsection{\1}')
|
118
135
|
|
119
136
|
# Enable proper cross-reference
|
120
|
-
s(/#{
|
121
|
-
s(/#{
|
122
|
-
s(/#{
|
137
|
+
s(/#{config['fig'].gsub(space, '\s')}\s*(\d+)\-\-(\d+)/, '\imgref{\1.\2}')
|
138
|
+
s(/#{config['tab'].gsub(space, '\s')}\s*(\d+)\-\-(\d+)/, '\tabref{\1.\2}')
|
139
|
+
s(/#{config['prechap'].gsub(space, '\s')}\s*(\d+)(\s*)#{config['postchap'].gsub(space, '\s')}/, '\chapref{\1}\2')
|
123
140
|
|
124
141
|
# Miscellaneous fixes
|
125
142
|
s(/FIG: (.*)/, '\img{\1}')
|
126
143
|
s('\begin{enumerate}[1.]', '\begin{enumerate}')
|
127
144
|
s(/(\w)--(\w)/, '\1-\2')
|
128
|
-
s(/``(.*?)''/, "#{
|
145
|
+
s(/``(.*?)''/, "#{config['dql']}\\1#{config['dqr']}")
|
129
146
|
|
130
147
|
# Typeset the maths in the book with TeX
|
131
148
|
s('\verb!p = (n(n-1)/2) * (1/2^160))!', '$p = \frac{n(n-1)}{2} \times \frac{1}{2^{160}}$)')
|
@@ -133,16 +150,20 @@ module Docfu
|
|
133
150
|
s(/\sx\s10\\\^\{\}(\d+)/, '\e{\1}')
|
134
151
|
|
135
152
|
# Convert inline-verbatims into \texttt (which is able to wrap)
|
136
|
-
s(/\\verb(\W)(.*?)\1/)
|
137
|
-
|
138
|
-
|
153
|
+
s(/\\verb(\W)(.*?)\1/ ,'\\texttt{\2}')
|
154
|
+
# s(/\\verb(\W)(.*?)\1/) do
|
155
|
+
# "{\\texttt{#{verbatim_sanitize($2)}}}"
|
156
|
+
# end
|
139
157
|
|
140
|
-
#
|
141
|
-
s(/
|
142
|
-
s(/(\\begin\{verbatim\}.*?\\end\{verbatim\})/m, '{\footnotesize\1}')
|
158
|
+
# Style Tables
|
159
|
+
s(/ctable\[pos = H, center, botcap\]\{..\}/ , 'ctable[pos = ht!, caption = ~ ,width = 130mm, center, botcap]{lX}')
|
143
160
|
|
144
161
|
# Shaded verbatim block
|
145
162
|
s(/(\\begin\{verbatim\}.*?\\end\{verbatim\})/m, '\begin{shaded}\1\end{shaded}')
|
163
|
+
|
164
|
+
# Ensure monospaced stuff is in a smaller font
|
165
|
+
# s(/(\\verb(\W).*?\2)/, '{\footnotesize\1}')
|
166
|
+
# s(/(\\begin\{verbatim\}.*?\\end\{verbatim\})/m, '{\footnotesize\1}')
|
146
167
|
end
|
147
168
|
end
|
148
169
|
|
@@ -13,18 +13,20 @@
|
|
13
13
|
\usepackage{booktabs}
|
14
14
|
\usepackage{indentfirst}
|
15
15
|
\usepackage{framed,color}
|
16
|
-
\usepackage{
|
17
|
-
\
|
16
|
+
\usepackage{caption}
|
17
|
+
\captionsetup{font=bf,position=below}
|
18
|
+
|
19
|
+
\usepackage{ctable}
|
18
20
|
|
19
21
|
\definecolor{shadecolor}{gray}{0.90}
|
20
22
|
|
21
|
-
\setromanfont[Mapping=tex-text,BoldFont=<%=
|
22
|
-
\setmonofont{<%=
|
23
|
+
\setromanfont[Mapping=tex-text,BoldFont=<%= config['bold'] %>]{<%= config['font'] %>}
|
24
|
+
\setmonofont[Scale=.85]{<%= config['mono'] %>}
|
23
25
|
|
24
26
|
\XeTeXlinebreaklocale{<%= lang %>}
|
25
|
-
<%=
|
27
|
+
<%= config['langrule'] %>
|
26
28
|
|
27
|
-
\settowidth{\parindent}{<%=
|
29
|
+
\settowidth{\parindent}{<%= config['indent'] %>}
|
28
30
|
|
29
31
|
\title{<%= info['title'] %>}
|
30
32
|
\author{<%= info['author'] %>}
|
@@ -38,13 +40,11 @@
|
|
38
40
|
\makeatother
|
39
41
|
|
40
42
|
\title{\textbf{\savedtitle}}
|
41
|
-
\author{\textbf{\savedauthor}\thanks{<%=
|
43
|
+
\author{\textbf{\savedauthor}\thanks{<%= config['thanks'] %>}}
|
42
44
|
\def\w3cdtfymd{\the\year-\ifnum\month<10 0\fi\the\month-\ifnum\day<10 0\fi\the\day}
|
43
45
|
\date{\w3cdtfymd}
|
44
46
|
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
|
45
47
|
|
46
|
-
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
|
47
|
-
\let\PBS=\PreserveBackslash
|
48
48
|
\makeatletter
|
49
49
|
\setlength\headheight{12\p@}
|
50
50
|
\setlength\headsep {.25in}
|
@@ -90,30 +90,31 @@
|
|
90
90
|
|
91
91
|
\newcounter{img}[chapter]
|
92
92
|
\renewcommand{\theimg}{\thechapter.\arabic{img}}
|
93
|
-
\newcommand{\img}[1]{\begin{figure}[
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
93
|
+
\newcommand{\img}[1]{\begin{figure}[ht!]
|
94
|
+
\refstepcounter{img}
|
95
|
+
\label{img:\theimg}
|
96
|
+
\centering\IfFileExists{figures/\theimg.pdf}{\includegraphics[width=\maxwidth]{figures/\theimg.pdf}}{\includegraphics[width=\maxwidth]{figures/\theimg.png}}
|
97
|
+
|
98
|
+
\caption{#1}
|
98
99
|
\end{figure}}
|
99
100
|
|
100
101
|
\newcounter{tab}[chapter]
|
101
102
|
\renewcommand{\thetab}{\thechapter.\arabic{tab}}
|
102
103
|
|
103
|
-
\newcommand{\prechap}{<%=
|
104
|
-
\newcommand{\postchap}{<%=
|
105
|
-
\newcommand{\presect}{<%=
|
106
|
-
\newcommand{\postsect}{<%=
|
104
|
+
\newcommand{\prechap}{<%= config['prechap'] %>}
|
105
|
+
\newcommand{\postchap}{<%= config['postchap'] %>}
|
106
|
+
\newcommand{\presect}{<%= config['presect'] %>}
|
107
|
+
\newcommand{\postsect}{<%= config['postsect'] %>}
|
107
108
|
\renewcommand{\chaptermark}[1]{\markboth{\textbf{\prechap \thechapter \postchap}\hspace*{1ex}#1}{}}
|
108
109
|
\renewcommand{\sectionmark}[1]{\markright{\textbf{\presect \thesection \postsect}\hspace*{1ex}#1}}
|
109
110
|
\newcommand{\chap}[1]{\newpage\thispagestyle{empty}\chapter{#1}\label{chap:\thechapter}}
|
110
111
|
\newcommand{\chapref}[1]{\hyperref[chap:#1]{\prechap #1\postchap}}
|
111
|
-
\newcommand{\imgref}[1]{\hyperref[img:#1]{<%=
|
112
|
-
\newcommand{\tabref}[1]{\hyperref[tab:#1]{<%=
|
112
|
+
\newcommand{\imgref}[1]{\hyperref[img:#1]{<%= config['fig'] %>#1}}
|
113
|
+
\newcommand{\tabref}[1]{\hyperref[tab:#1]{<%= config['tab'] %>#1}}
|
113
114
|
\newcommand{\e}[1]{$ \times 10^{#1}$}
|
114
|
-
\renewcommand{\contentsname}{<%=
|
115
|
-
\renewcommand{\figurename}{<%=
|
116
|
-
\renewcommand{\tablename}{<%=
|
115
|
+
\renewcommand{\contentsname}{<%= config['con'] %>}
|
116
|
+
\renewcommand{\figurename}{<%= config['fig'] %>}
|
117
|
+
\renewcommand{\tablename}{<%= config['tab'] %>}
|
117
118
|
|
118
119
|
\makeatletter
|
119
120
|
\def\@makechapterhead#1{%
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docfu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mixlib-cli
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.3.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.
|
37
|
+
version: 2.13.0
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
45
|
+
version: 2.13.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: yard
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 0.8.6.1
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.8.6.1
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: cucumber
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.
|
85
|
+
version: 1.3.5
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,23 +90,23 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.
|
93
|
+
version: 1.3.5
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: jeweler
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: '0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: simplecov
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,9 +170,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
170
|
- - ! '>='
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
|
-
segments:
|
174
|
-
- 0
|
175
|
-
hash: -67242471902472211
|
176
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
174
|
none: false
|
178
175
|
requirements:
|
@@ -181,8 +178,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
178
|
version: '0'
|
182
179
|
requirements: []
|
183
180
|
rubyforge_project:
|
184
|
-
rubygems_version: 1.8.
|
181
|
+
rubygems_version: 1.8.25
|
185
182
|
signing_key:
|
186
183
|
specification_version: 3
|
187
184
|
summary: Docs like a ninja
|
188
185
|
test_files: []
|
186
|
+
has_rdoc:
|