hologram 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/README.md +14 -1
- data/lib/hologram/doc_builder.rb +7 -2
- data/lib/hologram/doc_parser.rb +29 -5
- data/lib/hologram/template_variables.rb +1 -1
- data/lib/hologram/version.rb +1 -1
- data/spec/doc_builder_spec.rb +2 -0
- data/spec/doc_parser_spec.rb +1 -1
- data/spec/fixtures/source/components/bem.md +12 -0
- data/spec/fixtures/source/components/jekyll.md +7 -0
- data/spec/fixtures/styleguide/code.html +73 -0
- data/spec/fixtures/styleguide/jekyll.html +68 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bbee4bb5cc8c9c22b1e102dd0dfb5d4e0bf3399
|
4
|
+
data.tar.gz: 9d179e3adbc3e2845b06f584ad50565aa41c8583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd7de23120bde386cd1d1de46d11f72df1a165af983d61217ac2f06ef0ecc6f4bf8d833c6c61a8da26f636f71353d4dea3354e7297fe8fed345acecca1258613
|
7
|
+
data.tar.gz: f38eb0c5d036d72e16acac3705378de8de014e6dbed86f7813fe8833b4159a964adf63161cc158396b0316d7cb17a4cad8690477844e22d108dd5b092a6969f6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
#Changelog
|
2
2
|
|
3
|
+
##1.4.0 - 2015-03-29
|
4
|
+
|
5
|
+
New Features:
|
6
|
+
|
7
|
+
Joe Bartlett
|
8
|
+
* Allow markdown files to contain hologram yaml
|
9
|
+
|
10
|
+
Anthony Chen
|
11
|
+
* Add config option for allowing additional file extensions to be
|
12
|
+
processed
|
13
|
+
|
14
|
+
JD Cantrell
|
15
|
+
* Add config option to ignore specific paths and files.
|
16
|
+
|
17
|
+
Bug fixes:
|
18
|
+
|
19
|
+
Noppanit Charassinvichai and Ryan Mathews
|
20
|
+
* Correctly copy assets
|
21
|
+
|
22
|
+
JD Cantrell
|
23
|
+
* Use correct title for index category pages
|
24
|
+
* Make scss regex behave like sass regex
|
25
|
+
* Template variables for erb files no longer vary based on when the erb
|
26
|
+
is processed.
|
27
|
+
|
28
|
+
|
3
29
|
##1.3.0 - 2015-01-15
|
4
30
|
|
5
31
|
Spencer Hurst, Beatrice Peng, and Geoff Pleiss
|
data/README.md
CHANGED
@@ -163,11 +163,20 @@ Your config file needs to contain the following key/value pairs
|
|
163
163
|
that they are included on your pages. A simple way to do this is to add
|
164
164
|
`<link>` and `<script src=>` tags to the `_header.html` file.
|
165
165
|
|
166
|
+
* **ignore_paths**: (optional) a **list** of paths to ignore. This can be a file
|
167
|
+
name or a glob. Be sure to wrap globs in double quotes to keep yaml
|
168
|
+
from getting too upset (ie good:"*.erb" vs bad:*.erb).
|
169
|
+
|
166
170
|
* **nav_level**: (optional) Sets the level of section navigation desired.
|
167
171
|
`section` sets it to show sub navigation in top level sections.
|
168
172
|
`all` sets it to show sub navigation for all sections. `all` can be a bit
|
169
173
|
much, you'll probably want `section`.
|
170
174
|
|
175
|
+
* **custom_extensions**: (optional) Additional file extensions that will be
|
176
|
+
included in the parse. Accepts both a single value and an array. The
|
177
|
+
current supported file extensions are `.css`, `.scss`, `.less`, `.sass`,
|
178
|
+
`.styl`, `.js`, `.md`, `.markdown` and `.erb`.
|
179
|
+
|
171
180
|
* **exit_on_warnings**: (optional) Hologram displays warnings when there
|
172
181
|
are issues with your docs (e.g. if a component's parent is not found,
|
173
182
|
if the _header.html and/or _footer.html files aren't found)
|
@@ -213,7 +222,7 @@ Your config file needs to contain the following key/value pairs
|
|
213
222
|
- ./build
|
214
223
|
|
215
224
|
# Mark which category should be the index page
|
216
|
-
# Alternatively, you may have an index.md in the
|
225
|
+
# Alternatively, you may have an index.md in the source directory root
|
217
226
|
# folder instead of specifying this config.
|
218
227
|
index: basics
|
219
228
|
|
@@ -337,6 +346,10 @@ following keys:
|
|
337
346
|
component. If this is set, the current component will be displayed as
|
338
347
|
a section within the **parent**'s documentation, but only if it specifies
|
339
348
|
the same **category**, or allows the **category** to be inherited from its **parent**.
|
349
|
+
* **hologram**: (markdown only) To avoid conflicts with Jekyll and
|
350
|
+
other YAML+markdown formats, Markdown (`.md`) files must include a
|
351
|
+
`hologram: true` key/value pair in the YAML block to indicate that
|
352
|
+
it is intended to be processed by Hologram.
|
340
353
|
|
341
354
|
For example, you might have a component with the **name** *buttons* and
|
342
355
|
another component named *buttonSkins*. You could set the **parent** for
|
data/lib/hologram/doc_builder.rb
CHANGED
@@ -63,6 +63,8 @@ module Hologram
|
|
63
63
|
@exit_on_warnings = options['exit_on_warnings']
|
64
64
|
@code_example_templates = options['code_example_templates']
|
65
65
|
@code_example_renderers = options['code_example_renderers']
|
66
|
+
@custom_extensions = Array(options['custom_extensions'])
|
67
|
+
@ignore_paths = options.fetch('ignore_paths', [])
|
66
68
|
|
67
69
|
if @exit_on_warnings
|
68
70
|
DisplayMessage.exit_on_warnings!
|
@@ -132,7 +134,9 @@ module Hologram
|
|
132
134
|
end
|
133
135
|
|
134
136
|
def build_docs
|
135
|
-
doc_parser = DocParser.new(input_dir, index, @plugins, nav_level: @nav_level
|
137
|
+
doc_parser = DocParser.new(input_dir, index, @plugins, nav_level: @nav_level,
|
138
|
+
custom_extensions: @custom_extensions,
|
139
|
+
ignore_paths: @ignore_paths)
|
136
140
|
@pages, @categories = doc_parser.parse
|
137
141
|
|
138
142
|
if index && !@pages.has_key?(index + '.html')
|
@@ -151,7 +155,8 @@ module Hologram
|
|
151
155
|
# ignore . and .. directories and files that start with
|
152
156
|
# underscore
|
153
157
|
next if item == '.' or item == '..' or item.start_with?('_')
|
154
|
-
FileUtils.rm "#{output_dir}/#{item}", :force => true
|
158
|
+
FileUtils.rm "#{output_dir}/#{item}", :force => true if File.file?("#{output_dir}/#{item}")
|
159
|
+
FileUtils.rm_rf "#{output_dir}/#{item}" if File.directory?("#{output_dir}/#{item}")
|
155
160
|
FileUtils.cp_r "#{doc_assets_dir}/#{item}", "#{output_dir}/#{item}"
|
156
161
|
end
|
157
162
|
end
|
data/lib/hologram/doc_parser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Hologram
|
2
2
|
class DocParser
|
3
|
-
|
3
|
+
DEFAULT_SUPPORTED_EXTENSIONS = ['.css', '.scss', '.less', '.sass', '.styl', '.js', '.md', '.markdown', '.erb' ]
|
4
4
|
attr_accessor :source_path, :pages, :doc_blocks, :nav_level
|
5
5
|
|
6
6
|
def initialize(source_path, index_name = nil, plugins=[], opts={})
|
@@ -10,6 +10,9 @@ module Hologram
|
|
10
10
|
@nav_level = opts[:nav_level] || 'page'
|
11
11
|
@pages = {}
|
12
12
|
@output_files_by_category = {}
|
13
|
+
@supported_extensions = DEFAULT_SUPPORTED_EXTENSIONS
|
14
|
+
@supported_extensions += opts[:custom_extensions] if opts[:custom_extensions]
|
15
|
+
@ignore_paths = opts[:ignore_paths] || []
|
13
16
|
end
|
14
17
|
|
15
18
|
def parse
|
@@ -44,6 +47,8 @@ module Hologram
|
|
44
47
|
name = @index_name + '.html'
|
45
48
|
if @pages.has_key?(name)
|
46
49
|
@pages['index.html'] = @pages[name]
|
50
|
+
title, _ = @output_files_by_category.rassoc(name)
|
51
|
+
@output_files_by_category[title] = 'index.html'
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
@@ -69,9 +74,18 @@ module Hologram
|
|
69
74
|
end
|
70
75
|
|
71
76
|
def process_files(files, directory, doc_block_collection)
|
72
|
-
|
77
|
+
|
78
|
+
if !@ignore_paths.empty?
|
79
|
+
valid_files = files.select { |input_file|
|
80
|
+
@ignore_paths.select { |glob| File.fnmatch(glob, input_file) }.empty?
|
81
|
+
}
|
82
|
+
else
|
83
|
+
valid_files = files
|
84
|
+
end
|
85
|
+
|
86
|
+
valid_files.each do |input_file|
|
73
87
|
if input_file.end_with?('md')
|
74
|
-
|
88
|
+
process_markdown_file("#{directory}/#{input_file}", doc_block_collection)
|
75
89
|
elsif input_file.end_with?('erb')
|
76
90
|
@pages[File.basename(input_file, '.erb')] = {:erb => File.read("#{directory}/#{input_file}")}
|
77
91
|
else
|
@@ -80,6 +94,16 @@ module Hologram
|
|
80
94
|
end
|
81
95
|
end
|
82
96
|
|
97
|
+
def process_markdown_file(file, doc_block_collection)
|
98
|
+
file_str = File.read(file)
|
99
|
+
|
100
|
+
if file_str.match(/^-{3}\n.*hologram:\s*true.*-{3}/m)
|
101
|
+
doc_block_collection.add_doc_block(file_str, file)
|
102
|
+
else
|
103
|
+
@pages[File.basename(file, '.md') + '.html'] = {:md => file_str, :blocks => []}
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
83
107
|
def process_file(file, doc_block_collection)
|
84
108
|
file_str = File.read(file)
|
85
109
|
# get any comment blocks that match the patterns:
|
@@ -90,7 +114,7 @@ module Hologram
|
|
90
114
|
#comment, this fixes haml when using this comment style
|
91
115
|
hologram_comments = file_str.scan(/\s*\/\/doc\s*((( [^\n]*\n)|\n)+)/).map{ |arr| [arr[0].gsub(/^[ \t]{2}/,'')] }
|
92
116
|
else
|
93
|
-
hologram_comments = file_str.scan(
|
117
|
+
hologram_comments = file_str.scan(/\s*\/\*doc(.*?)\*\//m)
|
94
118
|
|
95
119
|
#check if scss file has sass comments
|
96
120
|
if hologram_comments.length == 0 and file.end_with?('.scss')
|
@@ -129,7 +153,7 @@ module Hologram
|
|
129
153
|
end
|
130
154
|
|
131
155
|
def is_supported_file_type?(file)
|
132
|
-
|
156
|
+
@supported_extensions.include?(File.extname(file)) and !Dir.exists?(file)
|
133
157
|
end
|
134
158
|
|
135
159
|
def get_file_name(str)
|
data/lib/hologram/version.rb
CHANGED
data/spec/doc_builder_spec.rb
CHANGED
@@ -252,6 +252,8 @@ describe Hologram::DocBuilder do
|
|
252
252
|
builder.build
|
253
253
|
expect(File.read(File.expand_path('../fixtures/styleguide/base_css.html', __FILE__))).to eq File.read(File.join(builder.destination, '.', 'base_css.html'))
|
254
254
|
expect(File.read(File.expand_path('../fixtures/styleguide/index.html', __FILE__))).to eq File.read(File.join(builder.destination, '.', 'index.html'))
|
255
|
+
expect(File.read(File.expand_path('../fixtures/styleguide/code.html', __FILE__))).to eq File.read(File.join(builder.destination, '.', 'code.html'))
|
256
|
+
expect(File.read(File.expand_path('../fixtures/styleguide/jekyll.html', __FILE__))).to eq File.read(File.join(builder.destination, '.', 'jekyll.html'))
|
255
257
|
end
|
256
258
|
end
|
257
259
|
end
|
data/spec/doc_parser_spec.rb
CHANGED
@@ -120,7 +120,7 @@ multi-parent
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'adds two categories to output_files_by_category' do
|
123
|
-
expect(output_files_by_category).to eql({'Foo'=>'foo.html', 'Base CSS'=>'base_css.html', 'Bar'=>'bar.html'})
|
123
|
+
expect(output_files_by_category).to eql({'Foo'=>'foo.html', 'Base CSS'=>'base_css.html', 'Bar'=>'bar.html', 'Code'=>'code.html'})
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width">
|
6
|
+
|
7
|
+
<title>My Style Guide Code</title>
|
8
|
+
|
9
|
+
<!-- Styleguide CSS -->
|
10
|
+
<link rel="stylesheet" href="static/css/doc.css">
|
11
|
+
<link rel="stylesheet" href="static/css/github.css">
|
12
|
+
|
13
|
+
<!-- CSS to be documented -->
|
14
|
+
<link rel="stylesheet" href="extra/css/screen.css">
|
15
|
+
</head>
|
16
|
+
|
17
|
+
<body>
|
18
|
+
<header class="header pbn" role="banner">
|
19
|
+
<div class="backgroundHighlight typeReversed1">
|
20
|
+
<div class="container">
|
21
|
+
<h1 class="h2 mvs">My Style Guide</h1>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
<div class="backgroundLowlight typeReversed1">
|
25
|
+
<div class="container">
|
26
|
+
<span>
|
27
|
+
<ul class="docNav listInline">
|
28
|
+
<!-- Add you pages here -->
|
29
|
+
<li><a href="index.html">Intro</a></li>
|
30
|
+
<li><a href="base_css.html">Base CSS</a></li>
|
31
|
+
</ul>
|
32
|
+
</span>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<!-- //header/container -->
|
36
|
+
</header>
|
37
|
+
|
38
|
+
<div class="content">
|
39
|
+
<section>
|
40
|
+
<div class="line">
|
41
|
+
|
42
|
+
<div class="col cols4">
|
43
|
+
<div class="componentMenu box boxBasic backgroundBasic">
|
44
|
+
<div class="boxBody pan">
|
45
|
+
<ul class="componentList listBorderedHover">
|
46
|
+
|
47
|
+
<li><a href="#bem">BEM-like class naming</a></li>
|
48
|
+
|
49
|
+
</ul>
|
50
|
+
</div>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<div class="main col cols20 lastCol">
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<h1 id="bem" class="styleguide">BEM-like class naming</h1>
|
59
|
+
<p class="styleguide">We use a BEM-like naming convention <a class="styleguide" href="http://cssguidelin.es/#bem-like-naming" title="http://cssguidelin.es/#bem-like-naming">similar to Harry Roberts'</a>:</p><div class="codeBlock">
|
60
|
+
<div class="highlight">
|
61
|
+
<pre>.block {}
|
62
|
+
.block__element {}
|
63
|
+
.block--modifier {}</pre>
|
64
|
+
</div>
|
65
|
+
</div> </div>
|
66
|
+
</div>
|
67
|
+
</section>
|
68
|
+
<footer>
|
69
|
+
The source code for this style guide is licensed under the MIT license.
|
70
|
+
</footer>
|
71
|
+
</div>
|
72
|
+
</body>
|
73
|
+
</html>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width">
|
6
|
+
|
7
|
+
<title>My Style Guide </title>
|
8
|
+
|
9
|
+
<!-- Styleguide CSS -->
|
10
|
+
<link rel="stylesheet" href="static/css/doc.css">
|
11
|
+
<link rel="stylesheet" href="static/css/github.css">
|
12
|
+
|
13
|
+
<!-- CSS to be documented -->
|
14
|
+
<link rel="stylesheet" href="extra/css/screen.css">
|
15
|
+
</head>
|
16
|
+
|
17
|
+
<body>
|
18
|
+
<header class="header pbn" role="banner">
|
19
|
+
<div class="backgroundHighlight typeReversed1">
|
20
|
+
<div class="container">
|
21
|
+
<h1 class="h2 mvs">My Style Guide</h1>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
<div class="backgroundLowlight typeReversed1">
|
25
|
+
<div class="container">
|
26
|
+
<span>
|
27
|
+
<ul class="docNav listInline">
|
28
|
+
<!-- Add you pages here -->
|
29
|
+
<li><a href="index.html">Intro</a></li>
|
30
|
+
<li><a href="base_css.html">Base CSS</a></li>
|
31
|
+
</ul>
|
32
|
+
</span>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<!-- //header/container -->
|
36
|
+
</header>
|
37
|
+
|
38
|
+
<div class="content">
|
39
|
+
<section>
|
40
|
+
<div class="line">
|
41
|
+
|
42
|
+
<div class="col cols4">
|
43
|
+
<div class="componentMenu box boxBasic backgroundBasic">
|
44
|
+
<div class="boxBody pan">
|
45
|
+
<ul class="componentList listBorderedHover">
|
46
|
+
|
47
|
+
</ul>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div class="main col cols20 lastCol">
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
<hr>
|
57
|
+
<p class="styleguide">layout: post</p>
|
58
|
+
<h2>title: Blogging Like a Hacker</h2>
|
59
|
+
<p class="styleguide">This is an example of a markdown file whose YAML frontmatter will
|
60
|
+
be ignored by Hologram.</p> </div>
|
61
|
+
</div>
|
62
|
+
</section>
|
63
|
+
<footer>
|
64
|
+
The source code for this style guide is licensed under the MIT license.
|
65
|
+
</footer>
|
66
|
+
</div>
|
67
|
+
</body>
|
68
|
+
</html>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hologram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JD Cantrell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redcarpet
|
@@ -180,9 +180,11 @@ files:
|
|
180
180
|
- spec/fixtures/renderer/valid_renderer.rb
|
181
181
|
- spec/fixtures/source/colors/colors.css
|
182
182
|
- spec/fixtures/source/components/background/backgrounds.css
|
183
|
+
- spec/fixtures/source/components/bem.md
|
183
184
|
- spec/fixtures/source/components/button/buttons.css
|
184
185
|
- spec/fixtures/source/components/button/skin/buttonSkins.css
|
185
186
|
- spec/fixtures/source/components/index.md
|
187
|
+
- spec/fixtures/source/components/jekyll.md
|
186
188
|
- spec/fixtures/source/config.yml
|
187
189
|
- spec/fixtures/source/config_multi_source.yml
|
188
190
|
- spec/fixtures/source/extra/css/screen.css
|
@@ -190,8 +192,10 @@ files:
|
|
190
192
|
- spec/fixtures/source/templates/_header.html
|
191
193
|
- spec/fixtures/source/templates/static/css/doc.css
|
192
194
|
- spec/fixtures/styleguide/base_css.html
|
195
|
+
- spec/fixtures/styleguide/code.html
|
193
196
|
- spec/fixtures/styleguide/extra/css/screen.css
|
194
197
|
- spec/fixtures/styleguide/index.html
|
198
|
+
- spec/fixtures/styleguide/jekyll.html
|
195
199
|
- spec/fixtures/styleguide/static/css/doc.css
|
196
200
|
- spec/hologram_markdown_renderer_spec.rb
|
197
201
|
- spec/link_helper_spec.rb
|
@@ -218,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
222
|
version: '0'
|
219
223
|
requirements: []
|
220
224
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.
|
225
|
+
rubygems_version: 2.4.5
|
222
226
|
signing_key:
|
223
227
|
specification_version: 4
|
224
228
|
summary: Build document type things.
|
@@ -237,9 +241,11 @@ test_files:
|
|
237
241
|
- spec/fixtures/renderer/valid_renderer.rb
|
238
242
|
- spec/fixtures/source/colors/colors.css
|
239
243
|
- spec/fixtures/source/components/background/backgrounds.css
|
244
|
+
- spec/fixtures/source/components/bem.md
|
240
245
|
- spec/fixtures/source/components/button/buttons.css
|
241
246
|
- spec/fixtures/source/components/button/skin/buttonSkins.css
|
242
247
|
- spec/fixtures/source/components/index.md
|
248
|
+
- spec/fixtures/source/components/jekyll.md
|
243
249
|
- spec/fixtures/source/config.yml
|
244
250
|
- spec/fixtures/source/config_multi_source.yml
|
245
251
|
- spec/fixtures/source/extra/css/screen.css
|
@@ -247,8 +253,10 @@ test_files:
|
|
247
253
|
- spec/fixtures/source/templates/_header.html
|
248
254
|
- spec/fixtures/source/templates/static/css/doc.css
|
249
255
|
- spec/fixtures/styleguide/base_css.html
|
256
|
+
- spec/fixtures/styleguide/code.html
|
250
257
|
- spec/fixtures/styleguide/extra/css/screen.css
|
251
258
|
- spec/fixtures/styleguide/index.html
|
259
|
+
- spec/fixtures/styleguide/jekyll.html
|
252
260
|
- spec/fixtures/styleguide/static/css/doc.css
|
253
261
|
- spec/hologram_markdown_renderer_spec.rb
|
254
262
|
- spec/link_helper_spec.rb
|