double_doc 2.0.1 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b493c229ee510da46837763b4a16a77430c1995
4
- data.tar.gz: f2221645c30250b611de735808feaff8901a9439
3
+ metadata.gz: 4bf0f5b64a04ff19b143dec8d636ec1739a93995
4
+ data.tar.gz: 45b58b67cc55f5694d76ca7287df6a1e6751f68f
5
5
  SHA512:
6
- metadata.gz: 2eb54cc44d17e555cad20baf5c19c329fbef31ed16af3e26a251e91030a7046042fcd72c7029bc132f5d45fcbb726ea93764b348134acd1736bda08bfcd0ba81
7
- data.tar.gz: b49bd054fecd71297b57c01deea107f3375be701d411349fa6a106d90cb538c8b008770b4d5397f9c42f690413cd761afd6e5cd2ac7b30cf022e4187ddd4f836
6
+ metadata.gz: 1099135bb55d66c3e947bac4628ac08f4b94507b4043231fa6ba5da4f65812a9b6130a64855b4977fd457c3b78480cede64fa7d9842c302dacdab74f3beba3d8
7
+ data.tar.gz: bc38df6d8cd3ba04685ac6a15aabf39e73d7f04ebf89f1819ea77a8491120dba84b206d00a20faeebf374ad71ad6b5a73ba5e8b118a4f6f035c487f49524930e
@@ -1,9 +1,9 @@
1
1
  module DoubleDoc
2
2
  class DocExtractor
3
3
  TYPES = {
4
- 'rb' => /\s*##\s?(.*)$/,
5
- 'js' => %r{\s*///\s?(.*)$}
6
- }.freeze
4
+ 'rb' => /(^\s*|\s+)##\s?(?<documentation_line>.*?)(?<newline_marker>\\?)$/,
5
+ 'js' => %r{(^\s*|\s+)///\s?(?<documentation_line>.*?)(?<newline_marker>\\?)$}
6
+ }.freeze
7
7
 
8
8
  def self.extract(source, options = {})
9
9
  case source
@@ -28,13 +28,20 @@ module DoubleDoc
28
28
  extractor = TYPES[options[:type]]
29
29
 
30
30
  add_empty_line = false
31
+ append_to_previous = false
31
32
  lines.each do |line|
32
33
  if match = line.match(extractor)
33
34
  if add_empty_line
34
35
  doc << ''
35
36
  add_empty_line = false
36
37
  end
37
- doc << match[1].rstrip
38
+ new_string = match[:documentation_line].rstrip
39
+ if append_to_previous
40
+ doc[-1] << new_string
41
+ else
42
+ doc << new_string
43
+ end
44
+ append_to_previous = !match[:newline_marker].empty?
38
45
  else
39
46
  add_empty_line = !doc.empty?
40
47
  end
@@ -6,17 +6,17 @@ require 'double_doc/client'
6
6
  module DoubleDoc
7
7
 
8
8
  ## ### Rake Task
9
- ## It is very easy to set up a rake task for generating your documentation. All you have to do is
10
- ## tell DoubleDoc what the input files are, and where you want the output to go. In the example,
11
- ## `double_doc` is picked to avoid conflicts with the `doc` rake task in rails.
9
+ ## Generate documentation by telling DoubleDoc what the input files are, and where the output should go.
10
+ ## In the example, `double_doc` is picked to avoid conflicts with the `doc` rake task in rails.
12
11
  ##
13
12
  ## ```ruby
14
13
  ## require 'double_doc'
15
14
  ##
16
- ## DoubleDoc::Task.new(:double_doc,
17
- ## :sources => 'doc/source/*.md',
18
- ## :md_destination => 'doc/generated',
19
- ## :html_destination => 'site'
15
+ ## DoubleDoc::Task.new(
16
+ ## :double_doc,
17
+ ## sources: 'doc/source/*.md',
18
+ ## md_destination: 'doc/generated',
19
+ ## html_destination: 'site'
20
20
  ## )
21
21
  ## ```
22
22
  ##
@@ -24,25 +24,24 @@ module DoubleDoc
24
24
  ##
25
25
  ## | name | Description
26
26
  ## | -------------------- | -----------
27
- ## | __sources__ | __Required__. This tells Double doc where to look for the source of the documentation. Can be either a string or an array of strings.
28
- ## | __md_destination__ | __Required__. This is the directory where you want the generated markdown files to go.
29
- ## | __html_destination__ | If you want a pretty HTML version of your documentation, all you have to do is to say where you want it.
30
- ## | __html_template__ | You can use your own custom ERB template for HTML rendering. Have a look in the one we ship with DoubleDoc for inspiration (templates/default.html.erb).
31
- ## | __html_renderer__ | If you want full control of the HTML rendering you can use your own implementation. Defaults to `DoubleDoc::HtmlRenderer`.
32
- ## | __html_css__ | You can use your own custom CSS document by specifying it's path here.
33
- ## | __title__ | The title you want in the generated HTML. Defaults to "Documentation".
34
- ##
35
- ## If you just want to use double_doc to generate your README.md for github, you should write your documentation in doc/README.md and put this in your Rakefile:
27
+ ## | __sources__ | __Required__. Documentation source directory (string or array of strings).
28
+ ## | __md_destination__ | __Required__. Directory where the generated markdown files should go.
29
+ ## | __html_destination__ | Where a pretty HTML version of the documentation should go.
30
+ ## | __html_template__ | Custom ERB template for HTML rendering, see default template for inspiration (templates/default.html.erb).
31
+ ## | __html_renderer__ | Custom html rendered, defaults to `DoubleDoc::HtmlRenderer`.
32
+ ## | __html_css__ | Custom CSS document path.
33
+ ## | __title__ | Title for generated HTML, defaults to "Documentation".
34
+ ## To generate a README.md for github, write documentation in doc/README.md and put this in the Rakefile:
36
35
  ##
37
36
  ## ```ruby
38
37
  ## require 'double_doc'
39
38
  ##
40
- ## DoubleDoc::Task.new(:double_doc, :sources => 'doc/README.md', :md_destination => '.')
39
+ ## DoubleDoc::Task.new(:double_doc, sources: 'doc/README.md', md_destination: '.')
41
40
  ## ```
42
41
  ##
43
- ## Then all you have to do is to run `rake double_doc`, and you will have a `readme.md` in the root of your project.
42
+ ## Then run `rake double_doc`, which will generate a `readme.md` in the root of the project.
44
43
  ##
45
- ## If you have a gh-pages branch set up in your repository, you can event run `rake doc:publish` to generate html documentation and push it to your github pages.
44
+ ## If a gh-pages branch exists, run `rake doc:publish` to generate html documentation and push it to your github pages.
46
45
  class Task
47
46
  include Rake::DSL if defined?(Rake::DSL)
48
47
 
@@ -60,7 +59,7 @@ module DoubleDoc
60
59
 
61
60
  desc "Generate markdown #{html_dst ? 'and HTML ' : ''}DoubleDoc documentation"
62
61
  generated_task = task(task_name => destinations) do |t, args|
63
- opts = args.merge(options.merge(:roots => roots))
62
+ opts = args.to_h.merge(options.merge(:roots => roots))
64
63
  client = DoubleDoc::Client.new(options[:sources], opts)
65
64
  client.process
66
65
  end
@@ -80,6 +79,7 @@ module DoubleDoc
80
79
  generated_task.execute(:html_destination => dir)
81
80
  html_files = Dir.glob(Pathname.new(dir) + '*.html')
82
81
 
82
+ # FIXME: fail when something fails and don't just continue
83
83
  `git add .`
84
84
  `git commit -n -m 'Updated documentation'`
85
85
  `git checkout gh-pages`
@@ -1,4 +1,4 @@
1
1
  ## ## DoubleDoc 2.0
2
2
  module DoubleDoc
3
- VERSION = "2.0.1"
3
+ VERSION = "2.1.1"
4
4
  end
data/readme.md CHANGED
@@ -2,22 +2,16 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/zendesk/double_doc.svg?branch=master)](https://travis-ci.org/zendesk/double_doc)
4
4
 
5
+ <!-- only modify doc/readme.md and not Readme.md -->
5
6
 
6
- One of the challenges you face when writing public documention for code or APIs, is that you have to remember to update the documentation
7
- when ever you change the API. The main reason why this is a problem is that very often the documentation lives very for from your code.
7
+ Write documentation with your code, to keep them in sync, ideal for public API docs.
8
8
 
9
- This is the problem DoubleDoc tries to solve.
10
-
11
- DoubleDoc allows you to write the documentation right where your code is, and you can combine it all into a well structured document.
12
-
13
- This document was generated using DoubleDoc, and the source of this project is a great source for inspiration for how to use DoubleDoc.
9
+ This document was generated using DoubleDoc from [doc/readme.md](doc/readme.md), and the source of this project is a great source for how to use DoubleDoc.
14
10
 
15
11
  ### Documentation Format
16
- You write your documentation in markdown right in your source code files by double commenting it:
17
-
12
+ Write documentation in markdown right in source code files by double commenting it:
18
13
  ```ruby
19
14
  class User < ActiveRecord::Base
20
-
21
15
  ## ```js
22
16
  ## {
23
17
  ## "id": 1,
@@ -27,9 +21,8 @@ class User < ActiveRecord::Base
27
21
  def as_json
28
22
  # this comment will not be included in the documentation
29
23
  # as it only has a single # character
30
- super(:only => [:id, :name])
24
+ super(only: [:id, :name])
31
25
  end
32
-
33
26
  end
34
27
 
35
28
  class UsersController < ApplicationController
@@ -39,22 +32,22 @@ class UsersController < ApplicationController
39
32
  ## #### Format
40
33
  ## @import app/models/user.rb
41
34
  def show
42
- render :json => User.find(params[:id])
35
+ render json: User.find(params[:id])
43
36
  end
44
37
  end
45
38
  ```
46
39
 
47
- You would then write a markdown document about your User API:
40
+ Then write a markdown document about User API:
48
41
 
49
42
  ## Users
50
- You can acces users in our system by using our REST API, blah blah blah...
43
+ Access users by using our REST API, blah blah blah...
51
44
 
52
45
  @import app/controllers/users_controller.rb
53
46
 
54
- And DoubleDoc will generate this markdown document for you:
47
+ And DoubleDoc will generate this markdown document:
55
48
 
56
49
  ## Users
57
- You can acces users in our system by using our REST API, blah blah blah...
50
+ Access users in by using our REST API, blah blah blah...
58
51
 
59
52
  ### Getting a User
60
53
  `GET /users/{id}.json`
@@ -68,17 +61,17 @@ And DoubleDoc will generate this markdown document for you:
68
61
  ```
69
62
 
70
63
  ### Rake Task
71
- It is very easy to set up a rake task for generating your documentation. All you have to do is
72
- tell DoubleDoc what the input files are, and where you want the output to go. In the example,
73
- `double_doc` is picked to avoid conflicts with the `doc` rake task in rails.
64
+ Generate documentation by telling DoubleDoc what the input files are, and where the output should go.
65
+ In the example, `double_doc` is picked to avoid conflicts with the `doc` rake task in rails.
74
66
 
75
67
  ```ruby
76
68
  require 'double_doc'
77
69
 
78
- DoubleDoc::Task.new(:double_doc,
79
- :sources => 'doc/source/*.md',
80
- :md_destination => 'doc/generated',
81
- :html_destination => 'site'
70
+ DoubleDoc::Task.new(
71
+ :double_doc,
72
+ sources: 'doc/source/*.md',
73
+ md_destination: 'doc/generated',
74
+ html_destination: 'site'
82
75
  )
83
76
  ```
84
77
 
@@ -86,33 +79,31 @@ The available options are:
86
79
 
87
80
  | name | Description
88
81
  | -------------------- | -----------
89
- | __sources__ | __Required__. This tells Double doc where to look for the source of the documentation. Can be either a string or an array of strings.
90
- | __md_destination__ | __Required__. This is the directory where you want the generated markdown files to go.
91
- | __html_destination__ | If you want a pretty HTML version of your documentation, all you have to do is to say where you want it.
92
- | __html_template__ | You can use your own custom ERB template for HTML rendering. Have a look in the one we ship with DoubleDoc for inspiration (templates/default.html.erb).
93
- | __html_renderer__ | If you want full control of the HTML rendering you can use your own implementation. Defaults to `DoubleDoc::HtmlRenderer`.
94
- | __html_css__ | You can use your own custom CSS document by specifying it's path here.
95
- | __title__ | The title you want in the generated HTML. Defaults to "Documentation".
96
-
97
- If you just want to use double_doc to generate your README.md for github, you should write your documentation in doc/README.md and put this in your Rakefile:
82
+ | __sources__ | __Required__. Documentation source directory (string or array of strings).
83
+ | __md_destination__ | __Required__. Directory where the generated markdown files should go.
84
+ | __html_destination__ | Where a pretty HTML version of the documentation should go.
85
+ | __html_template__ | Custom ERB template for HTML rendering, see default template for inspiration (templates/default.html.erb).
86
+ | __html_renderer__ | Custom html rendered, defaults to `DoubleDoc::HtmlRenderer`.
87
+ | __html_css__ | Custom CSS document path.
88
+ | __title__ | Title for generated HTML, defaults to "Documentation".
89
+ To generate a README.md for github, write documentation in doc/README.md and put this in the Rakefile:
98
90
 
99
91
  ```ruby
100
92
  require 'double_doc'
101
93
 
102
- DoubleDoc::Task.new(:double_doc, :sources => 'doc/README.md', :md_destination => '.')
94
+ DoubleDoc::Task.new(:double_doc, sources: 'doc/README.md', md_destination: '.')
103
95
  ```
104
96
 
105
- Then all you have to do is to run `rake double_doc`, and you will have a `readme.md` in the root of your project.
97
+ Then run `rake double_doc`, which will generate a `readme.md` in the root of the project.
106
98
 
107
- If you have a gh-pages branch set up in your repository, you can event run `rake doc:publish` to generate html documentation and push it to your github pages.
99
+ If a gh-pages branch exists, run `rake doc:publish` to generate html documentation and push it to your github pages.
108
100
 
109
101
  ### Notes
110
- DoubleDoc is tested as working on both ruby 1.8.7 and 1.9.3, but does not work on jruby because of its dependency on redcarpet.
102
+ - Tested on ruby 2.0+
103
+ - Does not work on jruby because of its dependency on redcarpet.
111
104
 
112
105
  ### TODO
113
- * Tests
114
106
  * Support for directory structures
115
- * Documentation for the Rake task
116
107
  * Documentation for the Guard
117
108
  * Add support for extracting documentation from JavaScript files
118
109
 
@@ -125,4 +116,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
125
116
 
126
117
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
127
118
 
128
- THE SOFTWARE IS PROVIDED “AS IS,” WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
119
+ THE SOFTWARE IS PROVIDED “AS IS,” WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: double_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-09 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -25,7 +25,35 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: maxitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mime-types
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bump
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - ">="
@@ -94,8 +122,8 @@ dependencies:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0.2'
97
- description: A simple framework for writing and generating beautiful documentation
98
- for your code
125
+ description: Write documentation with your code, to keep them in sync, ideal for public
126
+ API docs.
99
127
  email:
100
128
  - mick@staugaard.com
101
129
  executables: []
@@ -115,12 +143,7 @@ files:
115
143
  - readme.md
116
144
  - templates/default.html.erb
117
145
  - templates/screen.css
118
- - test/client_test.rb
119
- - test/doc_extractor_test.rb
120
- - test/html_generator_test.rb
121
- - test/import_handler_test.rb
122
- - test/test_helper.rb
123
- homepage: http://staugaard.github.com/double_doc
146
+ homepage: https://github.com/zendesk/double_doc
124
147
  licenses: []
125
148
  metadata: {}
126
149
  post_install_message:
@@ -139,13 +162,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
162
  version: '0'
140
163
  requirements: []
141
164
  rubyforge_project:
142
- rubygems_version: 2.4.5
165
+ rubygems_version: 2.4.5.1
143
166
  signing_key:
144
167
  specification_version: 4
145
168
  summary: Documentation right where you want it
146
- test_files:
147
- - test/client_test.rb
148
- - test/doc_extractor_test.rb
149
- - test/html_generator_test.rb
150
- - test/import_handler_test.rb
151
- - test/test_helper.rb
169
+ test_files: []
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe "import handler" do
4
- subject do
5
- DoubleDoc::Client.new(sources, options)
6
- end
7
-
8
- describe '#process' do
9
- let(:destination) { Dir.mktmpdir }
10
- let(:sources) { [Bundler.root + 'doc/readme.md'] }
11
- let(:options) { { :md_destination => destination, :roots => [Bundler.root], :quiet => true } }
12
-
13
- before do
14
- subject.process
15
- end
16
-
17
- it 'produces output at the md_destination' do
18
- File.exists?(destination + '/readme.md').must_equal true
19
- end
20
-
21
- describe 'with a missing directory' do
22
- let(:destination) { Dir.mktmpdir + '/tmp' }
23
-
24
- it 'creates the directory' do
25
- File.exists?(destination + '/readme.md').must_equal true
26
- end
27
- end
28
-
29
- describe 'with multiple sources' do
30
- let(:sources) { %w(readme todo).map{|f| Bundler.root + "doc/#{f}.md" } }
31
-
32
- it 'processes all sources' do
33
- File.exists?(destination + '/readme.md').must_equal true
34
- File.exists?(destination + '/todo.md').must_equal true
35
- end
36
- end
37
-
38
- describe 'producing html' do
39
- let(:options) { {
40
- :md_destination => destination,
41
- :html_destination => destination + '/html',
42
- :roots => [Bundler.root],
43
- :quiet => true
44
- } }
45
-
46
- it 'creates html files' do
47
- File.exists?(destination + '/html/readme.html').must_equal true
48
- end
49
- end
50
- end
51
- end
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe "the doc extractor" do
4
-
5
- def self.it_acts_like_an_extractor
6
- it "extracts documentation" do
7
- subject.must_match(/this line should be extracted/)
8
- subject.must_match(/this line should also be extracted/)
9
- end
10
-
11
- it "doesn't extract regular comments" do
12
- subject.wont_match(/this line should not be extracted/)
13
- end
14
-
15
- it "doesn't add any extra new-lines" do
16
- subject.must_match(/^this/m)
17
- subject.must_match(/extracted\n$/m)
18
- end
19
-
20
- it "adds an empty line between documentation sections" do
21
- subject.must_match(/extracted\n\nthis/m)
22
- end
23
- end
24
-
25
- describe "on .rb files" do
26
- ## this line should be extracted
27
- # this line should not be extracted
28
- ## this line should also be extracted
29
-
30
- subject do
31
- DoubleDoc::DocExtractor.extract(File.new(__FILE__))
32
- end
33
-
34
- it_acts_like_an_extractor
35
- end
36
-
37
- describe 'on .js files' do
38
- subject do
39
- source = <<-EOS
40
- /// this line should be extracted
41
- // this line should not be extracted
42
- /// this line should also be extracted
43
- EOS
44
- DoubleDoc::DocExtractor.extract(source, :type => 'js')
45
- end
46
-
47
- it_acts_like_an_extractor
48
- end
49
- end
@@ -1,95 +0,0 @@
1
- require 'test_helper'
2
- require 'pathname'
3
- require 'tmpdir'
4
-
5
- describe "the html generator" do
6
- before do
7
- @root = Pathname.new(Dir.mktmpdir)
8
- @input_file_name = @root + 'source/input.md'
9
- @destination = @root + 'destination'
10
- @output_file_name = @destination + 'input.html'
11
- Dir.mkdir(@root + 'source')
12
- Dir.mkdir(@destination)
13
- @generator = DoubleDoc::HtmlGenerator.new([@input_file_name], {
14
- :html_destination => @destination,
15
- :quiet => true
16
- })
17
- end
18
-
19
- after do
20
- FileUtils.rm_rf(@root)
21
- end
22
-
23
- describe "#generate" do
24
- before do
25
- File.open(@input_file_name, 'w') do |f|
26
- f.puts "## Hello"
27
- f.puts "and some text and a link to [the other file](other.md)"
28
- f.puts "and a link with params [params](params.md?foo=bar)"
29
- f.puts "and a link with a fragment [params](params.md#foo-bar)"
30
- end
31
-
32
- File.open(@destination + 'some_trash.html', 'w') do |f|
33
- f.puts 'what ever'
34
- end
35
-
36
- @generator.generate
37
- end
38
-
39
- it "should put an html document in the destination directory" do
40
- assert File.exist?(@output_file_name), 'did not create the html file'
41
- end
42
-
43
- it "should convert .md links to .html links" do
44
- output = File.read(@output_file_name)
45
- output.must_match(/<a href="other.html">the other file<\/a>/)
46
- output.must_match(/<a href="params.html\?foo=bar">params<\/a>/)
47
- output.must_match(/<a href="params.html#foo-bar">params<\/a>/)
48
- end
49
-
50
- end
51
-
52
- describe "navigation" do
53
- before do
54
- @input_file_one = @root + 'source/file_one.md'
55
- File.open(@input_file_one, 'w') do |f|
56
- f.puts "## Title One"
57
- end
58
-
59
- @input_file_two = @root + 'source/file_two.md'
60
- File.open(@input_file_two, 'w') do |f|
61
- f.puts "## Title Two"
62
- end
63
-
64
- @input_files = [@input_file_one, @input_file_two]
65
- end
66
-
67
- it "should generate links for each page in the navigation area" do
68
- generator = DoubleDoc::HtmlGenerator.new(@input_files, {
69
- :html_destination => @destination,
70
- :quiet => true
71
- })
72
- generator.generate
73
-
74
- output = File.read(@destination + 'file_one.html')
75
-
76
- output.must_match(/<li>\s*<a class="source" href="file_one.html">Title One<\/a>\s*<\/li>/)
77
- output.must_match(/<li>\s*<a class="source" href="file_two.html">Title Two<\/a>\s*<\/li>/)
78
- end
79
-
80
- it "should skip specified filed" do
81
- generator = DoubleDoc::HtmlGenerator.new(@input_files, {
82
- :html_destination => @destination,
83
- :exclude_from_navigation => ['file_two.html'],
84
- :quiet => true
85
- })
86
- generator.generate
87
-
88
- output = File.read(@destination + 'file_one.html')
89
-
90
- output.must_match(/<li>\s*<a class="source" href="file_one.html">Title One<\/a>\s*<\/li>/)
91
- output.wont_match(/<li>\s*<a class="source" href="file_two.html">Title Two<\/a>\s*<\/li>/)
92
- end
93
- end
94
-
95
- end
@@ -1,58 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe "import handler" do
4
- subject do
5
- roots = Array(root).push(options.merge( :quiet => true ))
6
- DoubleDoc::ImportHandler.new(*roots)
7
- end
8
-
9
- after do
10
- ENV["BUNDLE_GEMFILE"] = Bundler.root.join("Gemfile").to_s
11
- end
12
-
13
- describe "multiple roots" do
14
- let(:root) { [Bundler.root + 'lib', Bundler.root + 'doc'] }
15
- let(:options) {{}}
16
-
17
- it "finds files from either root" do
18
- subject.find_file("double_doc.rb").must_be_instance_of File
19
- subject.find_file("readme.md").must_be_instance_of File
20
- end
21
- end
22
-
23
- describe "with gemfile" do
24
- let(:root) { Bundler.root }
25
- let(:options) {{ :gemfile => true }}
26
-
27
- describe "rubygems" do
28
- describe "load_paths" do
29
- it "should add Gemfile load paths" do
30
- subject.load_paths.must_include root
31
- subject.load_paths.size.must_be :>, 1
32
- end
33
- end
34
-
35
- describe "find_file" do
36
- it "should resolve files" do
37
- subject.find_file("bundler.rb").must_be_instance_of File
38
- end
39
-
40
- it "should raise if unable to find file" do
41
- lambda do
42
- subject.find_file("nope.rb")
43
- end.must_raise LoadError
44
- end
45
- end
46
- end
47
-
48
- describe "find_file" do
49
- it "should resolve files from path" do
50
- subject.find_file("double_doc.rb").must_be_instance_of File
51
- end
52
-
53
- it "should resolve file from git" do
54
- subject.find_file("mime-types.rb").must_be_instance_of File
55
- end
56
- end
57
- end
58
- end
@@ -1,4 +0,0 @@
1
- require "bundler"
2
- Bundler.require
3
-
4
- require "minitest/autorun"