hologram 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/README.md +13 -8
- data/lib/hologram/doc_builder.rb +15 -8
- data/lib/hologram/version.rb +1 -1
- data/spec/display_message_spec.rb +1 -1
- data/spec/doc_parser_spec.rb +10 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df438fa1f7fdc30768d2cb9981932488d74ca9ae
|
4
|
+
data.tar.gz: cd01a07f936c9750d9a13146684bc9740a0723fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57a3a103b3f2af2580d0228c39f1ac74cf82d54e55e8cf6fc7b35b6a185c7d156e14809bdb0cc7111d409322e2179606fd3f0c95ab025d86139412ba5eac844d
|
7
|
+
data.tar.gz: 9dc0380bfce972458b69743ba4002ce376de9c1a335c8c65979203f9714bd93d4505e8b5b6ee635868c490b16a3154df19fbc2c40a3ab40ed42e3a8ddb6734a6
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Hologram
|
1
|
+
# Hologram [![Build Status](https://travis-ci.org/trulia/hologram.png)](https://travis-ci.org/trulia/hologram)
|
2
2
|
|
3
3
|
Hologram is a Ruby gem that parses comments in your CSS and helps you turn them into a beautiful style guide.
|
4
4
|
|
@@ -69,10 +69,15 @@ Your config file needs to contain the following key/value pairs
|
|
69
69
|
hologram generates.
|
70
70
|
|
71
71
|
Hologram treats `_header.html` and `_footer.html`
|
72
|
-
as ERB files for each page that is generated
|
73
|
-
`title`, `file_name`, and `
|
74
|
-
|
75
|
-
`
|
72
|
+
as ERB files for each page that is generated. You can access the
|
73
|
+
`title`, `file_name`, `blocks`, and `categories`.
|
74
|
+
|
75
|
+
`blocks` is a list of each documenation block on the page. Each item in the list has a `title`,
|
76
|
+
`name`, `category`, and optionally a `parent`. This is useful for,
|
77
|
+
say, building a menu that lists each component.
|
78
|
+
|
79
|
+
`categories` is a list of all the categories found in the documentation
|
80
|
+
|
76
81
|
**Nota Bene:** Filenames that begin with underscores will not be copied into the destination folder.
|
77
82
|
|
78
83
|
|
@@ -110,7 +115,7 @@ Your config file needs to contain the following key/value pairs
|
|
110
115
|
|
111
116
|
###Documenting your styles
|
112
117
|
|
113
|
-
Hologram will scan
|
118
|
+
Hologram will scan for stylesheets (.css, .scss, .sass, .less, or .styl) within the **source** directory defined in you configuraiton.
|
114
119
|
It will look for comments that match the following:
|
115
120
|
|
116
121
|
/*doc
|
@@ -139,10 +144,10 @@ The first section of the comment is a yaml block that defines certain
|
|
139
144
|
aspects of the this documentation block (more on that in the next section). The second part is simply
|
140
145
|
markdown as defined by Redcarpet.
|
141
146
|
|
142
|
-
Notice the use of `html_example`. This tells the markdown renderer that it should treat the example as...well...html. If your project uses [haml](http://haml.info/) you can also use `haml_example`. In that case the output will be html for the example and the code block will show the haml used to generate the html. For components that require [javascript](https://www.destroyallsoftware.com/talks/wat) you can use `js_example` for your
|
147
|
+
Notice the use of `html_example`. This tells the markdown renderer that it should treat the example as...well...html. If your project uses [haml](http://haml.info/) you can also use `haml_example`. In that case the output will be html for the example and the code block will show the haml used to generate the html. For components that require [javascript](https://www.destroyallsoftware.com/talks/wat) you can use `js_example` for your javascript. In addition to outputing the javascript in a `<code>` block it will also wrap it in a `<script>` tag for execution.
|
143
148
|
|
144
149
|
####Document YAML section
|
145
|
-
The yaml in the
|
150
|
+
The yaml in the documention block can have any key value pair you deem important
|
146
151
|
but it specifically looks for the following keys:
|
147
152
|
|
148
153
|
* **title**: The title to display in the documents
|
data/lib/hologram/doc_builder.rb
CHANGED
@@ -20,21 +20,28 @@ module Hologram
|
|
20
20
|
|
21
21
|
begin
|
22
22
|
@config = YAML::load_file(config_file)
|
23
|
+
rescue SyntaxError => e
|
24
|
+
DisplayMessage.error("Could not load config file, check the syntax or try 'hologram init' to get started")
|
23
25
|
rescue
|
24
26
|
DisplayMessage.error("Could not load config file, try 'hologram init' to get started")
|
25
27
|
end
|
26
28
|
|
27
|
-
|
29
|
+
if @config.is_a? Hash
|
28
30
|
|
29
|
-
|
30
|
-
base_path = Pathname.new(config_file)
|
31
|
-
Dir.chdir(base_path.dirname)
|
31
|
+
validate_config
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
current_path = Dir.pwd
|
34
|
+
base_path = Pathname.new(config_file)
|
35
|
+
Dir.chdir(base_path.dirname)
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
# the real work happens here.
|
38
|
+
build_docs
|
39
|
+
|
40
|
+
Dir.chdir(current_path)
|
41
|
+
DisplayMessage.success("Build completed. (-: ")
|
42
|
+
else
|
43
|
+
DisplayMessage.error("Could not read config file, check the syntax or try 'hologram init' to get started")
|
44
|
+
end
|
38
45
|
rescue RuntimeError => e
|
39
46
|
DisplayMessage.error("#{e}")
|
40
47
|
end
|
data/lib/hologram/version.rb
CHANGED
@@ -62,7 +62,7 @@ describe Hologram::DisplayMessage do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'displays an error in red' do
|
65
|
-
expect(display).to receive(:puts).with("\e[32m(
|
65
|
+
expect(display).to receive(:puts).with("\e[32m(\u{256F}\u{00B0}\u{25A1}\u{00B0}\u{FF09}\u{256F}\e[0m\e[31m\u{FE35} \u{253B}\u{2501}\u{253B} \e[0m\e[31m Build not complete.\e[0m")
|
66
66
|
expect(display).to receive(:puts).with(" foo")
|
67
67
|
|
68
68
|
begin
|
data/spec/doc_parser_spec.rb
CHANGED
@@ -35,11 +35,15 @@ eos
|
|
35
35
|
|
36
36
|
context '#parse' do
|
37
37
|
let(:result) { parser.parse }
|
38
|
+
let(:pages) { result[0] }
|
39
|
+
let(:categories) { result[1] }
|
38
40
|
|
39
|
-
it 'builds and returns a hash of pages' do
|
40
|
-
expect(
|
41
|
+
it 'builds and returns a hash of pages and a hash of categories' do
|
42
|
+
expect(pages).to be_a Hash
|
43
|
+
expect(categories).to be_a Hash
|
41
44
|
end
|
42
45
|
|
46
|
+
|
43
47
|
context 'when an index page is specified' do
|
44
48
|
subject(:parser) { Hologram::DocParser.new('spec/fixtures/source', 'foo') }
|
45
49
|
|
@@ -50,7 +54,7 @@ eos
|
|
50
54
|
end
|
51
55
|
|
52
56
|
it 'uses that page as the index' do
|
53
|
-
expect(
|
57
|
+
expect(pages['index.html'][:md]).to include 'Markdown stuff'
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
@@ -62,7 +66,7 @@ eos
|
|
62
66
|
end
|
63
67
|
|
64
68
|
it 'takes the category in a collection and treats them as the page names' do
|
65
|
-
expect(
|
69
|
+
expect(pages.keys).to include 'foo.html'
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
@@ -78,11 +82,11 @@ eos
|
|
78
82
|
end
|
79
83
|
|
80
84
|
it 'appends the child doc to the category page' do
|
81
|
-
expect(
|
85
|
+
expect(pages['base_css.html'][:md]).to include 'Some other style'
|
82
86
|
end
|
83
87
|
|
84
88
|
it 'assigns the child doc a deeper header' do
|
85
|
-
expect(
|
89
|
+
expect(pages['base_css.html'][:md]).to include '<h2 id="otherStyle">Some other style</h2>'
|
86
90
|
end
|
87
91
|
end
|
88
92
|
end
|
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.0.
|
4
|
+
version: 1.0.1
|
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: 2014-02-
|
12
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redcarpet
|
@@ -90,6 +90,7 @@ extensions: []
|
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
92
|
- .gitignore
|
93
|
+
- .travis.yml
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|