qdoc 0.0.23 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qdoc.rb +38 -19
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b2a3b0810bc5f07f4e658408dee9a017c389115
|
4
|
+
data.tar.gz: 17436f66490ded735a52d6eb70474b403d10c97f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a43620e478f79112abc288a886048fd56583ff1095e7b3fd82de5adc39ae9b5726925b1c1b2c96c02415542bc881c938217e5fc29053ba9e1bfd2365c79e5bf1
|
7
|
+
data.tar.gz: cede091c8d86c3715c16c4cd52a176f80918cb4b6a85e5d7ba8c865077ccabcce54be829055db26f46edd6800be6bebc8e560cb9aeb456513ff833af9cb5f74f
|
data/lib/qdoc.rb
CHANGED
@@ -3,11 +3,17 @@ require 'redcarpet'
|
|
3
3
|
require 'kramdown'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'cgi'
|
6
|
+
require 'nokogiri'
|
7
|
+
|
8
|
+
#
|
6
9
|
|
7
10
|
class QDoc
|
8
11
|
|
12
|
+
# Initializes QDoc
|
13
|
+
# [options[:output_directory] set the directory to be created for documentation
|
14
|
+
# [options#index_content] set the static index page message
|
9
15
|
def initialize( options = {} )
|
10
|
-
defaults = { output_directory: "doc", index_content: "Choose from the
|
16
|
+
defaults = { output_directory: "doc", index_content: "Choose from the list." }
|
11
17
|
options = defaults.merge options
|
12
18
|
@out_dir = options[:output_directory]
|
13
19
|
|
@@ -18,15 +24,15 @@ class QDoc
|
|
18
24
|
@redcarpet = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
|
19
25
|
end
|
20
26
|
|
27
|
+
# Causes QDoc to search the current directory and tree, and parse found files
|
21
28
|
def run
|
22
29
|
@locations = identify_locations
|
23
30
|
@documents = stage_files( @locations )
|
24
|
-
|
25
|
-
# index = nil
|
31
|
+
@index[:content] = create_index @documents
|
26
32
|
make_doc_directory
|
27
33
|
@documents.each do |doc|
|
28
34
|
doc[:content] = parse_document( doc ) if doc[:parse] #"#{doc[:directory]}/#{doc[:filename]}")
|
29
|
-
write_file( "#{@out_dir}/#{doc[:output_file]}", create_page(
|
35
|
+
write_file( "#{@out_dir}/#{doc[:output_file]}", create_page(doc[:content], doc[:title]) )
|
30
36
|
end
|
31
37
|
copy_bootstrap
|
32
38
|
end
|
@@ -48,16 +54,16 @@ class QDoc
|
|
48
54
|
locations
|
49
55
|
end
|
50
56
|
|
51
|
-
def create_index
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
57
|
+
# def create_index
|
58
|
+
# page = "<p>Choose from the list below to select a document</p>" + \
|
59
|
+
# "<p>#{@documents.count-1} files parsed from the following locations:<p>" + \
|
60
|
+
# "<table class='table table-striped'><tbody>"
|
61
|
+
# @locations.each do |l|
|
62
|
+
# l = "Current Dir" if l == ""
|
63
|
+
# page += "<tr><td>#{l}</td></tr>"
|
64
|
+
# end
|
65
|
+
# page += "</tbody></table></div>"
|
66
|
+
# end
|
61
67
|
|
62
68
|
def stage_files( locations )
|
63
69
|
documents = [ @index ]
|
@@ -106,17 +112,17 @@ class QDoc
|
|
106
112
|
text.gsub("ʻ", "‘").gsub("ā", "ā").gsub("ē","ē").gsub("ī", "ī").gsub("ō","ō").gsub("ū", "ū").gsub("Ā", "Ā").gsub("Ē","Ē").gsub("Ī", "Ī").gsub("Ō", "Ō").gsub("Ū", "Ū")
|
107
113
|
end
|
108
114
|
|
109
|
-
def create_page(
|
115
|
+
def create_page( content, title )
|
110
116
|
"<!DOCTYPE html>
|
111
117
|
<html>
|
112
118
|
<head>
|
113
|
-
<title>
|
119
|
+
<title>" + title + "</title>
|
114
120
|
<link href='bootstrap.min.css' rel='stylesheet'>
|
115
121
|
</head>
|
116
122
|
<body>
|
117
123
|
<div class='row'>
|
118
|
-
<div class='col-md-3'>" + \
|
119
|
-
|
124
|
+
<div class='col-md-3 hidden-print'>" + \
|
125
|
+
create_nav( content ) + \
|
120
126
|
"</div>
|
121
127
|
<div class='col-md-9'>" + \
|
122
128
|
content + \
|
@@ -125,7 +131,7 @@ class QDoc
|
|
125
131
|
</body>"
|
126
132
|
end
|
127
133
|
|
128
|
-
def
|
134
|
+
def create_index( documents )
|
129
135
|
snippet = "<table class='table table-striped'>
|
130
136
|
<thead>
|
131
137
|
<tr>
|
@@ -141,6 +147,19 @@ class QDoc
|
|
141
147
|
snippet += "</tbody></table>"
|
142
148
|
snippet
|
143
149
|
end
|
150
|
+
|
151
|
+
def create_nav( content )
|
152
|
+
value = '<div id="navbar-example" class="bs-sidebar affix" role="complementary" style=""> <ul class="nav bs-sidenav">' + "\n"
|
153
|
+
# value = "<ul class='nav'>"
|
154
|
+
headers = Hash.new
|
155
|
+
doc = Nokogiri::HTML content
|
156
|
+
headers[:level1] = doc.xpath('//h1') # Nokogiri::XML::NodeSet
|
157
|
+
headers[:level1].each do |h|
|
158
|
+
value += "<li><a href='#" + h.attributes['id'].value + "'>" + h.content + "</a></li>\n" if ! h.attributes.empty?
|
159
|
+
end
|
160
|
+
value += "</ul></div>"
|
161
|
+
value
|
162
|
+
end
|
144
163
|
|
145
164
|
def write_file( filename, content )
|
146
165
|
File.open(filename, "w") do |o|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Sereno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -38,8 +38,22 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.1.0
|
41
|
-
|
42
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.0
|
55
|
+
description: Allows you to create quick documents from textile or markdown into an
|
56
|
+
html format.
|
43
57
|
email: patrick@6orbits.com
|
44
58
|
executables:
|
45
59
|
- qdoc
|