Skip to content

Commit

Permalink
one way function linking from examples
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Jun 14, 2011
1 parent 271ec42 commit 5a2b8ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 3 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
TODO

* links to example usage from example docco'd code

* cross-link rocco code

* fix to group chooser

* version history for types, too

* only update certain tags / HEAD, force full update

* doc other branches (specify in config file)
Expand Down
2 changes: 2 additions & 0 deletions docurium.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Gem::Specification.new do |s|
s.rubyforge_project = 'docurium'

s.add_dependency "version_sorter", "~>1.1.0"
s.add_dependency "mustache", ">= 0.99.4"
s.add_dependency "rocco", "= 0.7.0"
s.add_development_dependency "bundler", "~>1.0"

s.files = `git ls-files`.split("\n")
Expand Down
15 changes: 14 additions & 1 deletion lib/docurium.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'pp'

class Docurium
Version = VERSION = '0.0.2'
Version = VERSION = '0.0.3'

attr_accessor :branch, :output_dir, :data

Expand Down Expand Up @@ -69,10 +69,22 @@ def generate_docs
end
files.each do |file|
out " # #{file}"

# highlight, roccoize and link
rocco = Rocco.new(file, files, {:language => 'c'})
rocco_layout = Rocco::Layout.new(rocco, tf)
rocco_layout.version = version
rf = rocco_layout.render

# look for function names in the examples and link
@data[:functions].each do |f, fdata|
rf.gsub!(f) do |f|
# save data for cross-link
"<a href=\"../../##{version}/group/#{fdata[:group]}/#{f}\">#{f}</a>"
end
end

# write example to docs directory
rf_path = File.basename(file).split('.')[0..-2].join('.') + '.html'
rel_path = "ex/#{version}/#{rf_path}"
rf_path = File.join(outdir, rel_path)
Expand Down Expand Up @@ -239,6 +251,7 @@ def group_functions
if !rest
group = value[:file].gsub('.h', '').gsub('/', '_')
end
@data[:functions][key][:group] = group
func[group] ||= []
func[group] << key
func[group].sort!
Expand Down
2 changes: 1 addition & 1 deletion lib/docurium/layout.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Jump To &hellip;
<div id="jump_wrapper">
<div id="jump_page">
<a class="source" href="/#{{ version }}">API Docs</a>
<a class="source" href="../../#{{ version }}">API Docs</a>
{{#sources}}
<a class="source" href="{{ url }}">{{ basename }}</a>
{{/sources}}
Expand Down

0 comments on commit 5a2b8ba

Please sign in to comment.