docurium 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +47 -5
- data/TODO.txt +3 -9
- data/bin/cm +10 -0
- data/docurium.gemspec +2 -0
- data/lib/docurium.rb +109 -21
- data/lib/docurium/cli.rb +17 -0
- data/lib/docurium/layout.mustache +45 -0
- data/lib/docurium/layout.rb +7 -0
- data/site/index.html +1 -1
- data/site/js/docurium.js +17 -0
- metadata +40 -6
data/README.md
CHANGED
@@ -4,30 +4,71 @@ Docurium is a lightweight Doxygen replacement. It generates static HTML from th
|
|
4
4
|
|
5
5
|
I built it to replace the Doxygen generated documentation for the libgit2 project, so I'm only currently testing it against that. So, it is only known to include support for features and keywords used in that project currently. If you have a C library project you try this on and something is amiss, please file an issue or better yet, a pull request.
|
6
6
|
|
7
|
+
Though Docurium can generate your docs into a subdirectory, it is meant to be served from a webserver, not locally. It uses XMLHttpRequest calls, which cannot be done locally, so you can't just open the index.html file locally and have it work - you need to either run a webserver in the output directory or push it to a website to view it properly. I use Pow (pow.cx) or GitHub Pages.
|
8
|
+
|
7
9
|
# Usage
|
8
10
|
|
9
11
|
Run the `cm` binary and pass it your Docurium config file.
|
10
12
|
|
11
13
|
$ cm doc api.docurium
|
12
|
-
* generating
|
13
|
-
- processing
|
14
|
-
- processing
|
14
|
+
* generating docs
|
15
|
+
- processing version v0.1.0
|
16
|
+
- processing version v0.2.0
|
17
|
+
- processing version v0.3.0
|
18
|
+
- processing version v0.8.0
|
19
|
+
- processing version v0.10.0
|
20
|
+
- processing version v0.11.0
|
21
|
+
- processing version v0.12.0
|
22
|
+
- processing version HEAD
|
23
|
+
* checking your api
|
24
|
+
- unmatched params in
|
25
|
+
git_commit_create
|
26
|
+
git_config_set_int
|
27
|
+
git_object_lookup_prefix
|
28
|
+
- signature changes in
|
29
|
+
git_index_get
|
30
|
+
git_repository_path
|
31
|
+
git_tree_entry_byindex
|
15
32
|
* output html in docs/
|
16
33
|
|
17
|
-
|
34
|
+
Docurium will tell you if you have unmatched @params entries in header docs and if you've changed signatures in functions in HEAD, just to help you know what's happening and if you've written your docs properly.
|
35
|
+
|
36
|
+
The Docurium config file looks like this:
|
18
37
|
|
19
38
|
{
|
20
39
|
"name": "libgit2",
|
21
40
|
"github": "libgit2/libgit2",
|
22
41
|
"input": "include/git2",
|
23
42
|
"prefix": "git_",
|
24
|
-
"
|
43
|
+
"branch": "gh-pages",
|
44
|
+
"examples": "examples",
|
25
45
|
"legacy": {
|
26
46
|
"input": {"src/git": ["v0.1.0"],
|
27
47
|
"src/git2": ["v0.2.0", "v0.3.0"]}
|
28
48
|
}
|
29
49
|
}
|
30
50
|
|
51
|
+
You can either have a `branch` or an `output` entry - `branch` will write your docs directly into a Git branch, `output` will write them to a subdirectory.
|
52
|
+
|
53
|
+
# Installing
|
54
|
+
|
55
|
+
$ gem install docurium
|
56
|
+
|
57
|
+
# Screenshots
|
58
|
+
|
59
|
+
## Main Page
|
60
|
+
|
61
|
+
![Main Page](https://img.skitch.com/20110614-c98pp6c9p9mn35jn4iskjim7hk.png)
|
62
|
+
|
63
|
+
Each version of your app has a landing page that lists out all the functions available. Functions that are new in that version from the previous version are highlighted in green, functions that have changed signatures are in orange.
|
64
|
+
|
65
|
+
## Function Page
|
66
|
+
|
67
|
+
![Func Page](https://img.skitch.com/20110614-mdasyhip3swxtngwxrce8wqy3h.png)
|
68
|
+
|
69
|
+
Each function has a page showing all the relevant info for that function including metadata extracted from Doxygen-style comments. I also list all the versions of the library that this function is included in and in which versions the signature changed.
|
70
|
+
|
71
|
+
|
31
72
|
# Contributing
|
32
73
|
|
33
74
|
If you want to fix or change something, please fork on GitHub, push your change to a branch named after your change and send me a pull request.
|
@@ -37,3 +78,4 @@ If you want to fix or change something, please fork on GitHub, push your change
|
|
37
78
|
MIT, see LICENCE file
|
38
79
|
|
39
80
|
|
81
|
+
# vim:ft=markdown
|
data/TODO.txt
CHANGED
@@ -1,19 +1,13 @@
|
|
1
1
|
TODO
|
2
2
|
|
3
|
-
* show unmatched params when compiling HEAD (-w?)
|
4
|
-
|
5
3
|
* links to example usage from example docco'd code
|
6
4
|
|
7
5
|
|
8
|
-
|
9
|
-
* write directly to branch
|
10
|
-
|
11
|
-
* gem-ize
|
12
|
-
|
13
|
-
* add to libgit2 project
|
14
|
-
|
6
|
+
* fix to group chooser
|
15
7
|
|
16
8
|
* only update certain tags / HEAD, force full update
|
17
9
|
|
10
|
+
* doc other branches (specify in config file)
|
11
|
+
|
18
12
|
* highlight menu item when selected
|
19
13
|
|
data/bin/cm
CHANGED
@@ -19,6 +19,16 @@ command :doc do |c|
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
desc 'Generate Docurium config file template'
|
23
|
+
long_desc 'Generate Docurium config file template'
|
24
|
+
command :gen do |c|
|
25
|
+
c.action do |global_options,options,args|
|
26
|
+
file = args.first || 'api.docurium'
|
27
|
+
Docurium::CLI.gen(file)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
22
32
|
pre { |global,command,options,args| true }
|
23
33
|
|
24
34
|
post { |global,command,options,args| true }
|
data/docurium.gemspec
CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = 'docurium'
|
16
16
|
|
17
17
|
s.add_dependency "version_sorter", "~>1.1.0"
|
18
|
+
s.add_dependency "mustache", ">= 0.99.4"
|
19
|
+
s.add_dependency "rocco", "= 0.7.0"
|
18
20
|
s.add_development_dependency "bundler", "~>1.0"
|
19
21
|
|
20
22
|
s.files = `git ls-files`.split("\n")
|
data/lib/docurium.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'tempfile'
|
3
3
|
require 'version_sorter'
|
4
|
+
require 'rocco'
|
5
|
+
require 'docurium/layout'
|
4
6
|
require 'pp'
|
5
7
|
|
6
8
|
class Docurium
|
7
|
-
Version = VERSION = '0.0.
|
9
|
+
Version = VERSION = '0.0.2'
|
8
10
|
|
9
11
|
attr_accessor :branch, :output_dir, :data
|
10
12
|
|
@@ -20,7 +22,7 @@ class Docurium
|
|
20
22
|
@data[:prefix] = option_version(version, 'input', '')
|
21
23
|
end
|
22
24
|
|
23
|
-
def option_version(version, option, default)
|
25
|
+
def option_version(version, option, default = nil)
|
24
26
|
if @options['legacy']
|
25
27
|
if valhash = @options['legacy'][option]
|
26
28
|
valhash.each do |value, versions|
|
@@ -34,23 +36,64 @@ class Docurium
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def generate_docs
|
37
|
-
|
39
|
+
out "* generating docs"
|
38
40
|
outdir = mkdir_temp
|
39
41
|
copy_site(outdir)
|
40
42
|
versions = get_versions
|
41
43
|
versions << 'HEAD'
|
42
44
|
versions.each do |version|
|
43
|
-
|
45
|
+
out " - processing version #{version}"
|
44
46
|
workdir = mkdir_temp
|
45
47
|
Dir.chdir(workdir) do
|
46
48
|
clear_data(version)
|
47
49
|
checkout(version, workdir)
|
48
|
-
puts "parsing headers"
|
49
50
|
parse_headers
|
50
51
|
tally_sigs(version)
|
51
|
-
|
52
|
-
|
52
|
+
end
|
53
|
+
|
54
|
+
tf = File.expand_path(File.join(File.dirname(__FILE__), 'docurium', 'layout.mustache'))
|
55
|
+
if ex = option_version(version, 'examples')
|
56
|
+
workdir = mkdir_temp
|
57
|
+
Dir.chdir(workdir) do
|
58
|
+
with_git_env(workdir) do
|
59
|
+
`git rev-parse #{version}:#{ex} 2>&1` # check that it exists
|
60
|
+
if $?.exitstatus == 0
|
61
|
+
out " - processing examples for #{version}"
|
62
|
+
`git read-tree #{version}:#{ex}`
|
63
|
+
`git checkout-index -a`
|
64
|
+
|
65
|
+
files = []
|
66
|
+
Dir.glob("**/*") do |file|
|
67
|
+
next if !File.file?(file)
|
68
|
+
files << file
|
69
|
+
end
|
70
|
+
files.each do |file|
|
71
|
+
out " # #{file}"
|
72
|
+
rocco = Rocco.new(file, files, {:language => 'c'})
|
73
|
+
rocco_layout = Rocco::Layout.new(rocco, tf)
|
74
|
+
rocco_layout.version = version
|
75
|
+
rf = rocco_layout.render
|
76
|
+
rf_path = File.basename(file).split('.')[0..-2].join('.') + '.html'
|
77
|
+
rel_path = "ex/#{version}/#{rf_path}"
|
78
|
+
rf_path = File.join(outdir, rel_path)
|
79
|
+
FileUtils.mkdir_p(File.dirname(rf_path))
|
80
|
+
File.open(rf_path, 'w+') do |f|
|
81
|
+
@data[:examples] ||= []
|
82
|
+
@data[:examples] << [file, rel_path]
|
83
|
+
f.write(rf)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
53
88
|
end
|
89
|
+
|
90
|
+
if version == 'HEAD'
|
91
|
+
show_warnings
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
File.open(File.join(outdir, "#{version}.json"), 'w+') do |f|
|
96
|
+
f.write(@data.to_json)
|
54
97
|
end
|
55
98
|
end
|
56
99
|
|
@@ -66,10 +109,26 @@ class Docurium
|
|
66
109
|
end
|
67
110
|
end
|
68
111
|
|
69
|
-
if @options['branch']
|
70
|
-
|
112
|
+
if br = @options['branch']
|
113
|
+
out "* writing to branch #{br}"
|
114
|
+
ref = "refs/heads/#{br}"
|
115
|
+
with_git_env(outdir) do
|
116
|
+
psha = `git rev-parse #{ref}`.chomp
|
117
|
+
`git add -A`
|
118
|
+
tsha = `git write-tree`.chomp
|
119
|
+
puts "\twrote tree #{tsha}"
|
120
|
+
if(psha == ref)
|
121
|
+
csha = `echo 'generated docs' | git commit-tree #{tsha}`.chomp
|
122
|
+
else
|
123
|
+
csha = `echo 'generated docs' | git commit-tree #{tsha} -p #{psha}`.chomp
|
124
|
+
end
|
125
|
+
puts "\twrote commit #{csha}"
|
126
|
+
`git update-ref -m 'generated docs' #{ref} #{csha}`
|
127
|
+
puts "\tupdated #{br}"
|
128
|
+
end
|
71
129
|
else
|
72
130
|
final_dir = File.join(@project_dir, @options['output'] || 'docs')
|
131
|
+
out "* output html in #{final_dir}"
|
73
132
|
FileUtils.mkdir_p(final_dir)
|
74
133
|
Dir.chdir(final_dir) do
|
75
134
|
FileUtils.cp_r(File.join(outdir, '.'), '.')
|
@@ -77,6 +136,32 @@ class Docurium
|
|
77
136
|
end
|
78
137
|
end
|
79
138
|
|
139
|
+
def show_warnings
|
140
|
+
out '* checking your api'
|
141
|
+
|
142
|
+
# check for unmatched paramaters
|
143
|
+
unmatched = []
|
144
|
+
@data[:functions].each do |f, fdata|
|
145
|
+
unmatched << f if fdata[:comments] =~ /@param/
|
146
|
+
end
|
147
|
+
if unmatched.size > 0
|
148
|
+
out ' - unmatched params in'
|
149
|
+
unmatched.sort.each { |p| out ("\t" + p) }
|
150
|
+
end
|
151
|
+
|
152
|
+
# check for changed signatures
|
153
|
+
sigchanges = []
|
154
|
+
@sigs.each do |fun, data|
|
155
|
+
if data[:changes]['HEAD']
|
156
|
+
sigchanges << fun
|
157
|
+
end
|
158
|
+
end
|
159
|
+
if sigchanges.size > 0
|
160
|
+
out ' - signature changes in'
|
161
|
+
sigchanges.sort.each { |p| out ("\t" + p) }
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
80
165
|
def get_versions
|
81
166
|
VersionSorter.sort(git('tag').split("\n"))
|
82
167
|
end
|
@@ -116,11 +201,17 @@ class Docurium
|
|
116
201
|
end
|
117
202
|
|
118
203
|
def checkout(version, workdir)
|
204
|
+
with_git_env(workdir) do
|
205
|
+
`git read-tree #{version}:#{@data[:prefix]}`
|
206
|
+
`git checkout-index -a`
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def with_git_env(workdir)
|
119
211
|
ENV['GIT_INDEX_FILE'] = mkfile_temp
|
120
212
|
ENV['GIT_WORK_TREE'] = workdir
|
121
213
|
ENV['GIT_DIR'] = File.join(@project_dir, '.git')
|
122
|
-
|
123
|
-
`git checkout-index -a`
|
214
|
+
yield
|
124
215
|
ENV.delete('GIT_INDEX_FILE')
|
125
216
|
ENV.delete('GIT_WORK_TREE')
|
126
217
|
ENV.delete('GIT_DIR')
|
@@ -398,11 +489,6 @@ class Docurium
|
|
398
489
|
block.strip
|
399
490
|
end
|
400
491
|
|
401
|
-
def write_branch
|
402
|
-
puts "Writing to branch #{@branch}"
|
403
|
-
puts "Done!"
|
404
|
-
end
|
405
|
-
|
406
492
|
def mkdir_temp
|
407
493
|
tf = Tempfile.new('docurium')
|
408
494
|
tpath = tf.path
|
@@ -414,13 +500,11 @@ class Docurium
|
|
414
500
|
def mkfile_temp
|
415
501
|
tf = Tempfile.new('docurium-index')
|
416
502
|
tpath = tf.path
|
417
|
-
tf.
|
503
|
+
tf.unlink
|
418
504
|
tpath
|
419
505
|
end
|
420
506
|
|
421
|
-
|
422
507
|
def copy_site(outdir)
|
423
|
-
puts "Copying site files to temp path (#{outdir})"
|
424
508
|
here = File.expand_path(File.dirname(__FILE__))
|
425
509
|
FileUtils.mkdir_p(outdir)
|
426
510
|
Dir.chdir(outdir) do
|
@@ -429,7 +513,11 @@ class Docurium
|
|
429
513
|
end
|
430
514
|
|
431
515
|
def write_dir
|
432
|
-
|
433
|
-
|
516
|
+
out "Writing to directory #{output_dir}"
|
517
|
+
out "Done!"
|
518
|
+
end
|
519
|
+
|
520
|
+
def out(text)
|
521
|
+
puts text
|
434
522
|
end
|
435
523
|
end
|
data/lib/docurium/cli.rb
CHANGED
@@ -6,5 +6,22 @@ class Docurium
|
|
6
6
|
doc.generate_docs
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.gen(file)
|
10
|
+
|
11
|
+
temp = <<-TEMPLATE
|
12
|
+
{
|
13
|
+
"name": "project",
|
14
|
+
"github": "user/project",
|
15
|
+
"input": "include/lib",
|
16
|
+
"prefix": "lib_",
|
17
|
+
"output": "docs"
|
18
|
+
}
|
19
|
+
TEMPLATE
|
20
|
+
puts "Writing to #{file}"
|
21
|
+
File.open(file, 'w+') do |f|
|
22
|
+
f.write(temp)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
9
26
|
end
|
10
27
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
+
<title>{{ title }}</title>
|
6
|
+
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div id='container'>
|
10
|
+
<div id="background"></div>
|
11
|
+
<div id="jump_to">
|
12
|
+
Jump To …
|
13
|
+
<div id="jump_wrapper">
|
14
|
+
<div id="jump_page">
|
15
|
+
<a class="source" href="../../#{{ version }}">API Docs</a>
|
16
|
+
{{#sources}}
|
17
|
+
<a class="source" href="{{ url }}">{{ basename }}</a>
|
18
|
+
{{/sources}}
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<table cellspacing=0 cellpadding=0>
|
23
|
+
<thead>
|
24
|
+
<tr>
|
25
|
+
<th class=docs><h1>{{ title }}</h1></th>
|
26
|
+
<th class=code></th>
|
27
|
+
</tr>
|
28
|
+
</thead>
|
29
|
+
<tbody>
|
30
|
+
{{#sections}}
|
31
|
+
<tr id='section-{{ section_id }}'>
|
32
|
+
<td class=docs>
|
33
|
+
<div class="pilwrap">
|
34
|
+
<a class="pilcrow" href="#section-{{ section_id }}">¶</a>
|
35
|
+
</div>
|
36
|
+
{{{ docs }}}
|
37
|
+
</td>
|
38
|
+
<td class=code>
|
39
|
+
<div class='highlight'><pre>{{{ code }}}</pre></div>
|
40
|
+
</td>
|
41
|
+
</tr>
|
42
|
+
{{/sections}}
|
43
|
+
</table>
|
44
|
+
</div>
|
45
|
+
</body>
|
data/site/index.html
CHANGED
data/site/js/docurium.js
CHANGED
@@ -482,6 +482,22 @@ $(function() {
|
|
482
482
|
filelist.hide()
|
483
483
|
menu.append(filelist)
|
484
484
|
|
485
|
+
// Examples List
|
486
|
+
if(data['examples'].length > 0) {
|
487
|
+
title = $('<h3><a href="#">Examples</a></h3>').click( this.collapseSection )
|
488
|
+
menu.append(title)
|
489
|
+
filelist = $('<ul>')
|
490
|
+
_.each(data['examples'], function(file) {
|
491
|
+
fname = file[0]
|
492
|
+
fpath = file[1]
|
493
|
+
flink = $('<a>').attr('href', fpath).append(fname)
|
494
|
+
fitem = $('<li>')
|
495
|
+
fitem.append(flink)
|
496
|
+
filelist.append(fitem)
|
497
|
+
}, this)
|
498
|
+
menu.append(filelist)
|
499
|
+
}
|
500
|
+
|
485
501
|
list = $('#files-list')
|
486
502
|
list.empty()
|
487
503
|
list.append(menu)
|
@@ -603,6 +619,7 @@ $(function() {
|
|
603
619
|
},
|
604
620
|
|
605
621
|
changelog: function(version, tname) {
|
622
|
+
docurium.setVersion()
|
606
623
|
docurium.showChangeLog()
|
607
624
|
},
|
608
625
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docurium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Scott Chacon
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-14 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,9 +35,41 @@ dependencies:
|
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: mustache
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 411
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 99
|
49
|
+
- 4
|
50
|
+
version: 0.99.4
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rocco
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - "="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 7
|
65
|
+
- 0
|
66
|
+
version: 0.7.0
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
41
73
|
none: false
|
42
74
|
requirements:
|
43
75
|
- - ~>
|
@@ -48,7 +80,7 @@ dependencies:
|
|
48
80
|
- 0
|
49
81
|
version: "1.0"
|
50
82
|
type: :development
|
51
|
-
version_requirements: *
|
83
|
+
version_requirements: *id004
|
52
84
|
description: A simpler, prettier Doxygen replacement.
|
53
85
|
email:
|
54
86
|
- schacon@gmail.com
|
@@ -68,6 +100,8 @@ files:
|
|
68
100
|
- docurium.gemspec
|
69
101
|
- lib/docurium.rb
|
70
102
|
- lib/docurium/cli.rb
|
103
|
+
- lib/docurium/layout.mustache
|
104
|
+
- lib/docurium/layout.rb
|
71
105
|
- site/css/style.css
|
72
106
|
- site/images/search_icon.png
|
73
107
|
- site/index.html
|