nandoc 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/README +5 -4
  2. data/Rakefile +1 -1
  3. data/bin/nandoc +2 -1
  4. data/doc/FAQ.md +3 -0
  5. data/doc/PROVISO.md +39 -0
  6. data/doc/commands/diff.md +49 -0
  7. data/doc/svg/less-fonts.svg +2 -2
  8. data/lib/nandoc/cli/README.md +6 -0
  9. data/lib/nandoc/cli/command-methods.rb +38 -0
  10. data/lib/nandoc/cli/option-methods/exclusive-options.rb +56 -0
  11. data/lib/nandoc/cli/option-methods/option-enum.rb +64 -0
  12. data/lib/nandoc/cli/option-methods.rb +35 -0
  13. data/lib/nandoc/cli.rb +3 -0
  14. data/lib/nandoc/commands/create-nandoc-site.rb +9 -12
  15. data/lib/nandoc/commands/diff.rb +14 -11
  16. data/lib/nandoc/commands.rb +9 -0
  17. data/lib/nandoc/{config.rb → core/config.rb} +18 -9
  18. data/lib/nandoc/core/project.rb +50 -0
  19. data/lib/nandoc/doc/hack-free-zone-defined.md +33 -0
  20. data/lib/nandoc/erb/agent.rb +5 -5
  21. data/lib/nandoc/{test/minitest-extlib.rb → extlib/minitest.rb} +1 -1
  22. data/lib/nandoc/filters/builtin-tags/fence/terminal.rb +24 -0
  23. data/lib/nandoc/filters/builtin-tags/fence-dispatcher.rb +43 -0
  24. data/lib/nandoc/filters/builtin-tags/fences.rb +4 -0
  25. data/lib/nandoc/filters/builtin-tags/see-test.rb +67 -0
  26. data/lib/nandoc/filters/builtin-tags.rb +11 -0
  27. data/lib/nandoc/filters/custom-tag.rb +43 -0
  28. data/lib/nandoc/filters/custom-tags.rb +19 -0
  29. data/lib/nandoc/filters/tag-parse-instance-methods.rb +11 -0
  30. data/lib/nandoc/filters/tag-parser.rb +206 -0
  31. data/lib/nandoc/filters.rb +11 -585
  32. data/lib/nandoc/{cri-hacks.rb → hacks/cri-hacks.rb} +4 -3
  33. data/lib/nandoc/{data-source.rb → hacks/data-source.rb} +5 -4
  34. data/lib/nandoc/{item-class-hacks.rb → hacks/item-class-hacks.rb} +3 -1
  35. data/lib/nandoc/hacks.rb +6 -0
  36. data/lib/nandoc/helpers/menu-bouncy.rb +1 -1
  37. data/lib/nandoc/helpers/site-map.rb +3 -0
  38. data/lib/nandoc/helpers.rb +1 -1
  39. data/lib/nandoc/html/tags.rb +65 -0
  40. data/lib/nandoc/html.rb +6 -0
  41. data/lib/nandoc/parse-readme.rb +4 -0
  42. data/lib/nandoc/spec-doc/agent-instance-methods.rb +24 -0
  43. data/lib/nandoc/spec-doc/code-snippet.rb +59 -0
  44. data/lib/nandoc/spec-doc/generic-agent.rb +40 -0
  45. data/lib/nandoc/spec-doc/mock-prompt.rb +3 -9
  46. data/lib/nandoc/spec-doc/parse-trace.rb +25 -0
  47. data/lib/nandoc/spec-doc/{mini-test/spec-instance-methods.rb → playback/html/foo-bar.rb} +0 -0
  48. data/lib/nandoc/spec-doc/playback/html.rb +2 -0
  49. data/lib/nandoc/spec-doc/playback/players/method.rb +64 -0
  50. data/lib/nandoc/spec-doc/playback/players/ruby.rb +158 -0
  51. data/lib/nandoc/spec-doc/playback/players/terminal.rb +93 -0
  52. data/lib/nandoc/spec-doc/playback/players.rb +4 -0
  53. data/lib/nandoc/spec-doc/playback/support/playback-methods.rb +44 -0
  54. data/lib/nandoc/spec-doc/playback/support/sexp-scanner.rb +61 -0
  55. data/lib/nandoc/spec-doc/playback/support.rb +3 -0
  56. data/lib/nandoc/spec-doc/playback/terminal/color-to-html.rb +100 -0
  57. data/lib/nandoc/spec-doc/playback.rb +3 -0
  58. data/lib/nandoc/spec-doc/recordings.rb +55 -0
  59. data/lib/nandoc/spec-doc/ruby2ruby-standin.rb +37 -0
  60. data/lib/nandoc/spec-doc/test-case-agent.rb +1 -1
  61. data/lib/nandoc/spec-doc/{mini-test.rb → test-framework/mini-test/proxy.rb} +9 -31
  62. data/lib/nandoc/spec-doc/{test-framework-proxy.rb → test-framework/proxy.rb} +27 -50
  63. data/lib/nandoc/spec-doc.rb +57 -13
  64. data/lib/nandoc/{test → support}/diff-to-string.rb +0 -0
  65. data/lib/nandoc/support/regexp-enhance.rb +6 -0
  66. data/lib/nandoc/support/regexp.rb +12 -0
  67. data/lib/nandoc/support/secret-parent.rb +21 -0
  68. data/lib/nandoc/support/shared-attr-reader.rb +32 -0
  69. data/lib/nandoc/support/site-merge.rb +1 -1
  70. data/lib/nandoc/support/site-methods.rb +4 -4
  71. data/lib/nandoc/support/stream-colorizer.rb +1 -1
  72. data/lib/nandoc/support/string-methods.rb +56 -0
  73. data/lib/nandoc.rb +12 -35
  74. data/proto/README.md +4 -2
  75. data/test/test.rb +1 -0
  76. metadata +58 -25
  77. data/doc/bar/baz.md +0 -4
  78. data/doc/bar/bliff.md +0 -8
  79. data/doc/foo.md +0 -5
  80. data/doc/getting-started.rb +0 -13
  81. data/lib/nandoc/spec-doc/support-modules.rb +0 -158
  82. data/lib/nandoc/spec-doc/test-framework-dispatcher.rb +0 -15
  83. data/lib/nandoc/support-modules.rb +0 -273
  84. data/lib/nandoc/treebis/NOGIT-DOCS/NEWS.md +0 -5
  85. data/lib/nandoc/treebis/NOGIT-README.md +0 -65
  86. data/lib/nandoc/treebis/nandoc.persistent.json +0 -3
data/README CHANGED
@@ -1,5 +1,4 @@
1
- <embed
2
- style='position: absolute; right:0; top:0'
1
+ <embed id='sunburst'
3
2
  src="svg/less-fonts.svg" width="150px" height="150px"
4
3
  type="image/svg+xml"
5
4
  pluginspage="http://www.adobe.com/svg/viewer/install/" />
@@ -9,7 +8,7 @@ this is a hack. this is nanDoc.
9
8
 
10
9
  ## Summary
11
10
 
12
- hack of [nanoc3](http://nanoc.stoneship.org) to generate a static site of your ruby project from your README etc.
11
+ hack of [nanoc3](http://nanoc.stoneship.org) to generate a static site of your (command-line) ruby project from your README etc.
13
12
 
14
13
  ## Description
15
14
 
@@ -65,10 +64,12 @@ To hack, try something like this:
65
64
  ~/tmp/nandoc > gem install -n ~/bin pkg/nandoc-0.0.0.gem
66
65
  ~~~
67
66
 
67
+ before actually trying to use it, if you get that far, please read this [proviso](/proviso).
68
+
68
69
 
69
70
  ## Usage Summary
70
71
 
71
- Start with a markdown-formatted README file:
72
+ Start with a markdown-formatted README file:
72
73
 
73
74
  (see: test.rb - "basic usage -- readme")
74
75
 
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ Jeweler::Tasks.new do |s|
17
17
  s.summary = NanDoc::ParseReadme.summary('README')
18
18
 
19
19
  s.add_dependency 'nanoc3', '~> 3.1.2'
20
- s.add_dependency 'treebis', '~> 0.0.1'
20
+ s.add_dependency 'treebis', '~> 0.0.2'
21
21
  s.add_dependency 'syntax', '~> 1.0.0'
22
22
  end
23
23
 
data/bin/nandoc CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
2
+ # $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
3
+ # above should be avoided when doing symlink hack
3
4
 
4
5
  require 'nandoc'
5
6
 
data/doc/FAQ.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Frequently Asked Questions
2
2
  <span style='font-size: 0.9em'><em>I can't walk 2 blocks outside my home without some stranger coming up to me and asking me one or more of these questions.</em></span>
3
3
 
4
+ ## Q: What about other test frameworks?
5
+ <p class='answer'>A: If you think you can patch nanDoc (SpecDoc) to work with your favorite testing framework, patches welcome!</p>
6
+
4
7
  ## Q: Why not jekyll?
5
8
  <p class='answer'>A: I started this knowing nothing about jekyll. nanoc3 found me and i was already acquainted with its author and i liked what i saw so i just ran with it without doing a broad survey of other solutions. At the time of this writing i still don't really know jekyll. @todo</p>
6
9
 
data/doc/PROVISO.md ADDED
@@ -0,0 +1,39 @@
1
+ # nanDoc
2
+
3
+ ## proviso
4
+
5
+
6
+ ### nanDoc is not nandoc
7
+
8
+ nanDoc is affiliated with nanoc by name only. They are separate projects with separate authors. Negative experiences with nan<em>Doc</em> should not inform your pre-judgement of nan<em>oc</em> and vice versa. (Positive experiences, however, should ;)
9
+
10
+ There is a uni-directional dependency upon nanoc by nanDoc. In nature this is classified as a parasitic as opposed to symbiotic relationship.
11
+
12
+ (-may 15, 2010)
13
+
14
+
15
+ ### nanDoc is alpha software
16
+
17
+ nanDoc is an experimental means to an end. I need a way to integrate code in my tests ("specs") with documentation generation to make sites like this for 4 or 5 of my gems. (If others find it useful along the way, ponies.)
18
+
19
+ breif discussions with the author of nanoc have lead me to believe that this use might be better served by looking at the `@example` tag available in YARD and [custom templates](http://gnuu.org/2009/11/18/customizing-yard-templates/) as opposed to going batshit insane with my wild hacks as i have thus far done;
20
+ but i do not have time to get up to speed on YARD now, much less overhaul nanDoc.
21
+
22
+ I find it equally likely that I won't like the YARD way and i will prefer the nanDoc way and i, like frank sinatra, will be glad i did it my way but this is all speculation at this point. Unfortunately i have no way of knowing what future me will think of present me, except that he will be jealous of how much hair I had back then.
23
+
24
+ i will to try to adhere to the [semantic versioning](http://semver.org/) standard for nanDoc versions. Fortunately for me and nanDoc at this point,
25
+ it states that:
26
+
27
+ > Major version zero (0.y.z) is for initial development. Anything may change
28
+ > at any time. The public API should not be considered stable.
29
+
30
+ This holds especially true for nanDoc which is very experimental and very much in flux for the time being, and as such will be in major and minor version zero for at least the next few months.
31
+
32
+ If, however, *anyone* uses nanDoc and finds some functionality of it *at all* useful, pls [email](<mailto:chip.malice@gmail.com>) me (or better yet ping `hipe` on [irc](irc://chat.freenode.net/#ruby-lang)) and I will very likely bake that functionality into what will ultimately become the public api for nanDoc.
33
+
34
+ (-may 13, 2010)
35
+
36
+
37
+
38
+
39
+ &#10087;
@@ -0,0 +1,49 @@
1
+ # NanDoc
2
+
3
+ ## Commands
4
+
5
+ ### `diff`
6
+
7
+ The diffing command is intended primarily as an internal development tool for me, in order to push and pull assets between my compiled site (the `my-site/output` folder), my content files of my site, (the `my-site/content` folder), and the assests modeled in the nanDoc site prototypes.
8
+
9
+
10
+ <div class='sidebar-right'>
11
+
12
+ <h4>push and pull?</h4>
13
+
14
+ <p>
15
+ <code>push</code> and <code>pull</code> don't have the typicical frame of reference here since there's no central server, just nodes on your filesystem. But their usage here corresponds to whether the direction in the flow of information is going <em>with</em> or <em>against</em> the "typical" direction.
16
+ </p>
17
+
18
+ <p>
19
+ The typical direction is <em>from</em> the nandoc site prototype <em>to</em> your <code>my-site/content</code> directory (when you first create the nanDoc site), and then (with the nanoc3 <code>compile</code> command) <em>from</em> the content directory _to_ the output directory. When you are changing files <em>down</em>on (or <em>later</em> in, or <em>to the right</em> of) this chain with new information from files <code>up</code> in this chain, i call it "<em>pushing</em>", else "<em>pulling</em>". I think.
20
+ </p>
21
+
22
+ </div>
23
+
24
+
25
+ However, end users may find this command useful for the following:
26
+
27
+ * fix your css files in your output/ directory, then once you get them right, pull that change back into your content/ directory, so the next time you `nandoc co` (compile) it will create css files with this new css. (@todo what is the normal nanoc workflow for this?)
28
+
29
+ * if you get a new version of nanDoc or somehow elsewise have a new site prototype, you can review and push changes from the new assets in the prototype to the assets in your `content/` directory.
30
+
31
+
32
+ #### pulling css from output back to content folders
33
+
34
+ This is most commonly what I use diffing for, so it is the easiest to type out, because the default destination node is the content directory, and the default subset node to compare is the css folder.
35
+
36
+ <div class='clear'></div>
37
+
38
+
39
+ For now, I must refer you to this jibber jabber:
40
+
41
+ from the command line:
42
+ ~~~
43
+ ~/my-gem/my-site/ > nandoc help diff
44
+ @todo
45
+ ~~~
46
+
47
+ gotta go!
48
+
49
+ &#10087;
@@ -3,8 +3,8 @@
3
3
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
4
  <!-- Generated by hipe version 0.0.0 (20100126.1600)
5
5
  -->
6
- <svg width="175" height="175"
7
- viewBox="0.00 0.00 175.00 175.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
6
+ <svg width="175" height="150"
7
+ viewBox="0.00 0.00 150.00 175.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
8
8
  <g id="blah1" class="whatevs" transform="scale(1 1) rotate(0) translate(0 0)">
9
9
  <title>this_some_awesome_thing</title>
10
10
  <polygon fill="white" stroke="white" points="5,140 5,0 140,0 140,140 5,140"/>
@@ -0,0 +1,6 @@
1
+ ## hack free zone
2
+
3
+ The intended audience of this document is developers of nanDoc, not developers using nanDoc.
4
+
5
+ This tiny cli library is hereby declared as a `hack free zone`
6
+ What that means will be defined in @todo link
@@ -0,0 +1,38 @@
1
+ module NanDoc
2
+ module Cli
3
+ module CommandMethods
4
+ # @depends none
5
+
6
+ def command_name
7
+ (/::([_a-z0-9]+)\Z/i =~ self.class.to_s and base = $1) or fail('no')
8
+ base.gsub(/([a-z])([A-Z])/){ "#{$1}-#{$2}" }.downcase
9
+ end
10
+ def invite_to_more_command_help
11
+ "see `nandoc help #{command_name}` for more information."
12
+ end
13
+ def command_path_assert name, *paths
14
+ paths.each do |p|
15
+ unless File.exist?(p)
16
+ command_abort("#{name} does not exist: #{p}")
17
+ end
18
+ end
19
+ end
20
+ def invocation_name
21
+ File.basename($PROGRAM_NAME)
22
+ end
23
+ def command_abort msg=nil
24
+ if msg.nil?
25
+ tail = 'Aborting.'
26
+ elsif msg.index("for more info") # not mr. right, mr. right now
27
+ tail = ''
28
+ else
29
+ last = msg[-1].chr
30
+ tail = ".?!".index(last) ? ' ' : ("\n"==last ? '' : '. ')
31
+ tail << 'Aborting.'
32
+ end
33
+ $stderr.puts "nanDoc: #{msg}#{tail}"
34
+ exit 1
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,56 @@
1
+ module NanDoc
2
+ module Cli
3
+ class ExclusiveOptions
4
+ include OptionMethods
5
+ def initialize &block
6
+ @exclusive_flag_keys = nil
7
+ @default_short = nil
8
+ @default_key = nil
9
+ @notice_stream = $stderr
10
+ instance_eval(&block)
11
+ fail('definition block needs at least flags()') unless
12
+ @exclusive_flag_keys
13
+ end
14
+ def flags * exclusive_flag_keys
15
+ @exclusive_flag_keys = exclusive_flag_keys
16
+ end
17
+ # params: [short_name_string] name_key
18
+ def default *a
19
+ if a.first.kind_of?(String)
20
+ @default_short = a.shift
21
+ end
22
+ if a.first.kind_of?(Symbol)
23
+ @default_key = a.shift
24
+ else
25
+ fail("bad args: #{a.first.inspect}")
26
+ end
27
+ fail("extra args: #{a.inspect}") if a.any?
28
+ end
29
+ def notice_stream mixed
30
+ @notice_stream = mixed
31
+ end
32
+ def parse cmd, opts
33
+ these = @exclusive_flag_keys & opts.keys
34
+ if these.empty? && @default_key
35
+ if @notice_stream
36
+ msg =
37
+ ["using default: "+unnormalize_opt_key(@default_key),
38
+ @default_short ? "(#{@default_short})" : nil
39
+ ].compact.join(' ')
40
+ @notice_stream.puts msg
41
+ end
42
+ these.push(@default_key)
43
+ end
44
+ if these.size > 1
45
+ flags = unnormalize_opt_keys(@exclusive_flag_keys)
46
+ cmd.command_abort <<-ABORT.gsub(/^ */,'')
47
+ #{flags.join(' and ')} are mutually exclusive.
48
+ usage: #{cmd.usage}
49
+ #{cmd.invite_to_more_command_help}
50
+ ABORT
51
+ end
52
+ these.first
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,64 @@
1
+ require 'nandoc/support/string-methods'
2
+
3
+ module NanDoc::Cli::OptionMethods
4
+ class OptionEnum
5
+
6
+ # @todo are we using this?
7
+
8
+ include NanDoc::StringMethods # oxford_comma
9
+
10
+ def initialize(&block)
11
+ instance_eval(&block)
12
+ end
13
+ def command cmd
14
+ @command = cmd
15
+ end
16
+ def default str
17
+ @default = str
18
+ end
19
+ def name name
20
+ @name = name
21
+ end
22
+ def parse opts
23
+ found = nil
24
+ if opts.key?(@name)
25
+ v = opts[@name]
26
+ re = /\A#{Regexp.escape(v)}/
27
+ founds = @values.grep(re)
28
+ case founds.size
29
+ when 0; invalid(v)
30
+ when 1; found = founds.first
31
+ else found = founds.detect{|f| f==v} or too_many(founds)
32
+ end
33
+ elsif(@default)
34
+ found = @default
35
+ else
36
+ found = nil
37
+ end
38
+ opts[@name] = found if found # normalize short versions
39
+ found
40
+ end
41
+ def values *v
42
+ v = v.first if v.size==1 && Array === v
43
+ @values = v
44
+ end
45
+ private
46
+ def coda
47
+ "usage: #{@command.usage}\n#{@command.invite_to_more_command_help}"
48
+ end
49
+ def invalid val
50
+ @command.command_abort("invalid value #{val.inspect} for "<<
51
+ "#{long_name}. #{valid_values_are}\n#{coda}")
52
+ end
53
+ def long_name
54
+ unnormalize_opt_key(@name)
55
+ end
56
+ def too_many these
57
+ @command.command_abort("did you mean " <<
58
+ oxford_comma(these,' or ', &quoted)<<" for #{long_name}?\n#{coda}")
59
+ end
60
+ def valid_values_are
61
+ "valid values are " << oxford_comma(@values,&quoted)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,35 @@
1
+ module NanDoc
2
+ module Cli
3
+ module OptionMethods
4
+ #
5
+ # only call this if you are like a ::Cri::Command object with
6
+ # all the nanDoc hacks. ick. This is a temprary hack. Trollop et al
7
+ # do this better.
8
+ #
9
+ def exclusive_opt_flags opts, &block
10
+ require File.dirname(__FILE__)+'/option-methods/exclusive-options.rb'
11
+ ExclusiveOptions.new(&block).parse(self, opts)
12
+ end
13
+ def normalize_opts opts
14
+ opts = opts.dup
15
+ opts.keys.select{|x| x.to_s.index('-') }.each do |k|
16
+ opts[normalize_opt_key(k)] = opts.delete(k)
17
+ end
18
+ opts
19
+ end
20
+ def option_enum
21
+ require File.dirname(__FILE__)+'/option-methods/option-enum.rb'
22
+ OptionEnum
23
+ end
24
+ def normalize_opt_key k
25
+ k.to_s.gsub('-','_').to_sym
26
+ end
27
+ def unnormalize_opt_keys keys
28
+ keys.map{|x| unnormalize_opt_key(x)}
29
+ end
30
+ def unnormalize_opt_key key
31
+ "--#{key.to_s.gsub('_','-')}"
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/nandoc/cli.rb ADDED
@@ -0,0 +1,3 @@
1
+ me = File.dirname(__FILE__)
2
+ require me + '/cli/command-methods.rb'
3
+ require me + '/cli/option-methods.rb'
@@ -7,7 +7,8 @@ module NanDoc
7
7
  #
8
8
 
9
9
 
10
- include OptsNormalizer, TaskCommon, CliCommandHelpers
10
+ include Cli::CommandMethods
11
+ include Cli::OptionMethods
11
12
 
12
13
  def name; 'create_nandoc_site' end
13
14
 
@@ -95,10 +96,10 @@ module NanDoc
95
96
  # not sure where to put this
96
97
  initiate_the_supreme_hack_of_the_standard_error_stream
97
98
 
98
- task_abort("you can't have both -M and -m") if
99
+ command_abort("you can't have both -M and -m") if
99
100
  opts[:merge_hack] && opts[:merge_hack_reverse]
100
101
  if opts[:datasource]
101
- task_abort <<-ABO.gsub(/\n */,"\n").strip
102
+ command_abort <<-ABO.gsub(/\n */,"\n").strip
102
103
  for now datasource is hardcoded to be nandoc.
103
104
  usage: #{usage}
104
105
  ABO
@@ -116,10 +117,6 @@ module NanDoc
116
117
  $stderr.puts(*a)
117
118
  end
118
119
 
119
- def my_exit
120
- exit(1);
121
- end
122
-
123
120
  #
124
121
  # see SupremeStderrHack
125
122
  #
@@ -138,7 +135,7 @@ module NanDoc
138
135
  def prototype_determine opts
139
136
  proto_name = opts[:prototype] || 'default'
140
137
  require 'nandoc/support/treebis-extlib' # experimental
141
- proto_path = "#{NanDoc::Root}/proto/#{proto_name}"
138
+ proto_path = "#{Config.proto_path}/#{proto_name}"
142
139
  @treebis_task = Treebis.dir_task(proto_path)
143
140
  end
144
141
 
@@ -159,18 +156,18 @@ module NanDoc
159
156
  if args.empty?
160
157
  err "missing <path> argument."
161
158
  err usage
162
- my_exit
159
+ command_abort
163
160
  end
164
161
  if args.size > 1
165
162
  err "Too many arguments"
166
163
  err usage
167
- my_exit
164
+ command_abort
168
165
  end
169
166
  path = args.first
170
167
  if File.exist?(path) && Dir[path+'/*'].any?
171
168
  err "folder already exists (no merge yet): #{path}"
172
169
  err usage
173
- my_exit
170
+ command_abort
174
171
  end
175
172
  if ! File.exist?(path)
176
173
  fu = Config.file_utils
@@ -184,7 +181,7 @@ module NanDoc
184
181
  def site_already_exists opts, args
185
182
  path = args.first
186
183
  if ! (opts[:merge_hack] || opts[:merge_hack_reverse])
187
- task_abort <<-FOO.gsub(/^ +/,'').chop
184
+ command_abort <<-FOO.gsub(/^ +/,'').chop
188
185
  A site at '#{path}' already exists.
189
186
  If you want to try and merge in changes from the site generator
190
187
  (this might just generate a diff), try the --merge-hack (-m) option.
@@ -6,7 +6,10 @@ require support + '/site-methods.rb'
6
6
  module NanDoc::Commands
7
7
  class Diff < ::Cri::Command
8
8
  NanDoc.persistent_delegate_to(self) # persistent_set(), persistent_get()
9
- include NanDoc::CliCommandHelpers, NanDoc::PathTardo, NanDoc::SiteMethods
9
+ include NanDoc::Cli::CommandMethods
10
+ include NanDoc::Cli::OptionMethods
11
+ include NanDoc::PathTardo
12
+ include NanDoc::SiteMethods
10
13
 
11
14
  def name; 'diff' end
12
15
 
@@ -95,7 +98,7 @@ module NanDoc::Commands
95
98
  path_src = deduce_subfolder_path site_path, src
96
99
  path_dst = deduce_subfolder_path site_path, dest
97
100
  if path_src == path_dst
98
- task_abort("source and destination paths are the same. "<<
101
+ command_abort("source and destination paths are the same. "<<
99
102
  "did you forget -p or -P ?\nusage: #{usage}\n"<<
100
103
  invite_to_more_command_help)
101
104
  end
@@ -123,7 +126,7 @@ module NanDoc::Commands
123
126
 
124
127
  def deduce_layout_paths src, dest, site_path
125
128
  if [src, dest].index(:output)
126
- task_abort "Sorry, it doesn't make sense to look at layout " <<
129
+ command_abort "Sorry, it doesn't make sense to look at layout " <<
127
130
  "in output directory because there is none.\n" <<
128
131
  "Please use -P or -p to compare layout btwn proto and <my-site>.\n"<<
129
132
  "usage: #{usage}\n#{invite_to_more_command_help}"
@@ -148,8 +151,8 @@ module NanDoc::Commands
148
151
  else; fail("unimplemented subset: #{subset}")
149
152
  end
150
153
  src_path, dest_path = paths
151
- assert_path "source path", src_path
152
- assert_path "destination path", dest_path
154
+ command_path_assert "source path", src_path
155
+ command_path_assert "destination path", dest_path
153
156
  [src_path, dest_path]
154
157
  end
155
158
 
@@ -182,7 +185,7 @@ module NanDoc::Commands
182
185
  when :diff_root_subset; diff_root_subset(src_path, dest_path)
183
186
  end
184
187
  if diff.error?
185
- task_abort diff.error
188
+ command_abort diff.error
186
189
  end
187
190
  diff
188
191
  end
@@ -218,7 +221,7 @@ module NanDoc::Commands
218
221
 
219
222
  def subsets
220
223
  cmd = self
221
- @subsets ||= OptEnum.new do |oe|
224
+ @subsets ||= option_enum.new do |oe|
222
225
  command cmd
223
226
  name :subset
224
227
  values %w(css layouts js root)
@@ -231,10 +234,10 @@ module NanDoc::Commands
231
234
  result = path_tardo(config, 'data_sources/[0]/site_prototype')
232
235
  if result.found?
233
236
  thing_in_config = result.value
234
- full_path = "proto/#{thing_in_config}"
237
+ full_path = NanDoc::Config.proto_path+"/#{thing_in_config}"
235
238
  full_path
236
239
  else
237
- task_abort(
240
+ command_abort(
238
241
  result.error_message + " in " + config_path_for_site_path(site_path)
239
242
  )
240
243
  end
@@ -244,7 +247,7 @@ module NanDoc::Commands
244
247
  def process_diff_opts opts
245
248
  if (bad = opts.keys & PatchPassThru).any?
246
249
  bads = bad.map{|x| unnormalize_opt_key(x)}.join('and')
247
- task_abort "#{bads} cannot be used with diffing only patching.\n"<<
250
+ command_abort "#{bads} cannot be used with diffing only patching.\n"<<
248
251
  "usage: #{usage}\n#{invite_to_more_command_help}"
249
252
  end
250
253
  end
@@ -265,7 +268,7 @@ module NanDoc::Commands
265
268
  def process_patch_opts_for_directory switch_h, opts, src, dest, site_path
266
269
  return unless opts[:subset] == 'root'
267
270
  if ! opts[:proto_to_content]
268
- task_abort("we need to test this for root patching for this target")
271
+ command_abort("we need to test this for root patching for this target")
269
272
  end
270
273
  # it's not explicitly an available pass-thru option
271
274
  fail("huh?") if switch_h['--directory'] ||
@@ -0,0 +1,9 @@
1
+ me = File.dirname(__FILE__)
2
+ require 'nandoc/cli'
3
+ require me + '/commands/create-nandoc-site.rb'
4
+ require me + '/commands/diff.rb'
5
+
6
+ shared_base = Nanoc3::CLI::Base.shared_base
7
+ shared_base.remove_command Nanoc3::CLI::Commands::CreateSite
8
+ shared_base.add_command NanDoc::CreateNanDocSite.new
9
+ shared_base.add_command NanDoc::Commands::Diff.new
@@ -2,18 +2,14 @@ module NanDoc
2
2
  module Config
3
3
  extend self
4
4
 
5
- #
6
- # this name etc etc
7
- #
8
-
9
- @orphan_surrogate_filename = Root + '/proto/misc/orphan-surrogate.md'
10
- attr_accessor :orphan_surrogate_filename
11
-
5
+ # items appear alphabetically. thought about using dsl for config like ramaze
6
+ # but nah. why bother.
12
7
 
13
8
  #
14
- # in the future make this smarter. i don't like now nanoc handles color
9
+ # Whether to output cli output in color. Without color probably doesn't work
10
+ # @todo in the future make this smarter. i don't like now nanoc handles color
15
11
  # (a command line argument?) There should be an autodetect, and/or set
16
- # last setting in sticky json file; or however it is it is done. @todo
12
+ # last setting in sticky json file; or however it is it is done.
17
13
  #
18
14
  def colorize?
19
15
  true
@@ -68,6 +64,19 @@ module NanDoc
68
64
  option_prefix_no_color
69
65
  end
70
66
 
67
+ root = ::Gem::GemPathSearcher.new.find('nandoc').full_gem_path
68
+
69
+ @orphan_surrogate_filename = root + '/proto/misc/orphan-surrogate.md'
70
+ attr_accessor :orphan_surrogate_filename
71
+
72
+ Treebis::PersistentDotfile.extend_to(NanDoc,
73
+ './nandoc.persistent.json',
74
+ :file_utils => self.file_utils
75
+ )
76
+
77
+ @proto_path = root + '/proto'
78
+ attr_accessor :proto_path
79
+
71
80
  #
72
81
  # other parts of the app include this module to get convenience methods
73
82
  # to some of the config nodes.
@@ -0,0 +1,50 @@
1
+ require 'singleton'
2
+ module NanDoc
3
+ class Project
4
+ #
5
+ # manages figuring out where folders are for things like tests,
6
+ # and builds test framework proxies for running tests
7
+ #
8
+
9
+ include Singleton
10
+ private
11
+ def initialize
12
+ end
13
+ public
14
+
15
+ # not especially robust at all
16
+ def project_root
17
+ @project_root ||= begin
18
+ presumed_root = File.dirname(FileUtils.pwd)
19
+ thems = %w(spec test)
20
+ found = thems.detect{ |dir| File.directory?(presumed_root+'/'+dir) }
21
+ fail("couldn't find " <<
22
+ StringMethods.oxford_comma(thems,' or ', &quoted) <<
23
+ "in #{presumed_root}") unless found
24
+ presumed_root
25
+ end
26
+ end
27
+
28
+ def require_test_file testfile
29
+ path = testdir + '/' + testfile
30
+ fail("test file not found: #{path.inspect}") unless File.file?(path)
31
+ require path
32
+ end
33
+
34
+ def testdir
35
+ @testdir ||= begin
36
+ tries = [project_root+'/test', project_root+'/spec']
37
+ found = tries.detect{ |path| File.directory?(path) }
38
+ fail("Couldn't find test dir for gem at (#{tries*', '})") unless found
39
+ found
40
+ end
41
+ end
42
+
43
+ def test_framework_proxy_for_file path
44
+ @the_only_proxy ||= begin
45
+ require 'nandoc/spec-doc/test-framework/mini-test/proxy'
46
+ SpecDoc::TestFramework::MiniTest::Proxy.new
47
+ end
48
+ end
49
+ end
50
+ end