shomen 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby +43 -0
- data/.yardopts +7 -0
- data/HISTORY.rdoc +10 -0
- data/NOTES.rdoc +5 -0
- data/README.rdoc +68 -0
- data/bin/shomen +4 -0
- data/lib/shomen.yml +43 -0
- data/lib/shomen/cli.rb +22 -0
- data/lib/shomen/cli/abstract.rb +120 -0
- data/lib/shomen/cli/rdoc.rb +122 -0
- data/lib/shomen/cli/tomdoc.rb +119 -0
- data/lib/shomen/cli/yard.rb +118 -0
- data/lib/shomen/core_ext/hash.rb +3 -0
- data/lib/shomen/metadata.rb +81 -0
- data/lib/shomen/model.rb +21 -0
- data/lib/shomen/model/abstract.rb +84 -0
- data/lib/shomen/model/attribute.rb +25 -0
- data/lib/shomen/model/class.rb +19 -0
- data/lib/shomen/model/constant.rb +34 -0
- data/lib/shomen/model/document.rb +36 -0
- data/lib/shomen/model/interface.rb +35 -0
- data/lib/shomen/model/method.rb +104 -0
- data/lib/shomen/model/module.rb +56 -0
- data/lib/shomen/model/script.rb +49 -0
- data/lib/shomen/rdoc.rb +598 -0
- data/lib/shomen/rdoc/extensions.rb +145 -0
- data/lib/shomen/server.rb +10 -0
- data/lib/shomen/tomdoc.rb +151 -0
- data/lib/shomen/yard.rb +471 -0
- data/spec/01_metadata.rdoc +24 -0
- data/spec/02_class.rdoc +63 -0
- data/spec/03_module.rdoc +59 -0
- data/spec/04_constant.rdoc +59 -0
- data/spec/05_method.rdoc +286 -0
- data/spec/08_rdoc/01_interface_overloading.rdoc +94 -0
- data/spec/09_yard/01_interface_overloading.rdoc +93 -0
- data/spec/applique/shomen.rb +26 -0
- data/spec/fixture/lib/example.rb +52 -0
- metadata +122 -0
data/.ruby
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
authors:
|
3
|
+
- name: Thomas Sawyer
|
4
|
+
email: transfire@gmail.com
|
5
|
+
copyrights: []
|
6
|
+
replacements: []
|
7
|
+
conflicts: []
|
8
|
+
requirements:
|
9
|
+
- name: rdoc
|
10
|
+
version: 3~
|
11
|
+
- name: detroit
|
12
|
+
groups:
|
13
|
+
- build
|
14
|
+
development: true
|
15
|
+
- name: reap
|
16
|
+
groups:
|
17
|
+
- build
|
18
|
+
development: true
|
19
|
+
dependencies: []
|
20
|
+
repositories:
|
21
|
+
- uri: git://github.com/rubyworks/shomen.git
|
22
|
+
scm: git
|
23
|
+
name: upstream
|
24
|
+
resources:
|
25
|
+
home: http://rubyworks.github.com/shomen
|
26
|
+
work: http://github.com/rubyworks/shomen
|
27
|
+
docs: http://github.com/rubyworks/shomen/wiki
|
28
|
+
load_path:
|
29
|
+
- lib
|
30
|
+
extra:
|
31
|
+
manifest: MANIFEST
|
32
|
+
source: []
|
33
|
+
alternatives: []
|
34
|
+
revision: 0
|
35
|
+
name: shomen
|
36
|
+
title: Shomen
|
37
|
+
summary: Standardized Object-Oriented Documentation Model
|
38
|
+
created: '2010-07-01'
|
39
|
+
description: Shomen defines a standard API documentaiton format for object-oriented
|
40
|
+
software (Ruby programs in particular) which can be used by documentation interfaces,
|
41
|
+
e.g. Hypervisor, to render API documentation
|
42
|
+
version: 0.1.0
|
43
|
+
date: '2011-10-05'
|
data/.yardopts
ADDED
data/HISTORY.rdoc
ADDED
data/NOTES.rdoc
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
= Shomen
|
2
|
+
|
3
|
+
{Website}[http://rubyworks.github.com/shomen] |
|
4
|
+
{User Manual}[http://github.com/rubyworks/shomen/wiki] |
|
5
|
+
{Development}[http://github.com/rubyworks/shomen]
|
6
|
+
|
7
|
+
|
8
|
+
== Description
|
9
|
+
|
10
|
+
Shomen is an intermediary documentation model designed for documenting
|
11
|
+
object-oriented programming languages, particularly Ruby. The specification
|
12
|
+
is a flat mapping, without internal referencing, suitable for storage in both
|
13
|
+
YAML and JSON formats.
|
14
|
+
|
15
|
+
|
16
|
+
== Why?
|
17
|
+
|
18
|
+
By using a standard intermediary format, documentation parsers need only concern
|
19
|
+
themselves with a single output target. And documentation templates in turn only
|
20
|
+
need to concern themselves with a single input format to use regardless of the
|
21
|
+
parsing system that was used to generate it.
|
22
|
+
|
23
|
+
|
24
|
+
== Features
|
25
|
+
|
26
|
+
* Update a single portable file to update documentation.
|
27
|
+
* Site disc footprint is extra small thanks to CDNs.
|
28
|
+
* Personalize site design to best fit your project.
|
29
|
+
* Test drive other's customizations with your own remote docs!
|
30
|
+
|
31
|
+
|
32
|
+
== Learn
|
33
|
+
|
34
|
+
To learn more about shomen please vist:
|
35
|
+
|
36
|
+
* http://rubyworks.github.com/shomen
|
37
|
+
* http://github.com/rubyworks/shomen/wiki
|
38
|
+
|
39
|
+
|
40
|
+
== Usage
|
41
|
+
|
42
|
+
Shomen currently supports parsing via RDoc and YARD. Specify the parser to
|
43
|
+
use to the shomen command, e.g.
|
44
|
+
|
45
|
+
$ shomen rdoc lib [A-Z]*.* -m README.rdoc > site/doc.json
|
46
|
+
|
47
|
+
If a `.document` file exists, of course, the file globs can be omitted.
|
48
|
+
For yard it's basically the same deal.
|
49
|
+
|
50
|
+
$ shomen yard lib [A-Z]*.* -r README.rdoc > site/doc.json
|
51
|
+
|
52
|
+
YARD will use `.yardopts` if it is present, so you genetally do not need to
|
53
|
+
to specify any parameters, e.g.
|
54
|
+
|
55
|
+
$ shomen yard > site/doc.json
|
56
|
+
|
57
|
+
Now that you have a Shomen documentation file for you project, you simply need
|
58
|
+
to pair it up with a viewer. Currently that means using {HyperVisor}[http://github.com/rubyworks/hypervisor].
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
== Copying
|
63
|
+
|
64
|
+
Copyright (c) 2010 Thomas Sawyer
|
65
|
+
|
66
|
+
Shomen is distributed under the terms of the BSD-2-Clause license.
|
67
|
+
|
68
|
+
See COPYING.rdoc for license details.
|
data/bin/shomen
ADDED
data/lib/shomen.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
authors:
|
3
|
+
- name: Thomas Sawyer
|
4
|
+
email: transfire@gmail.com
|
5
|
+
copyrights: []
|
6
|
+
replacements: []
|
7
|
+
conflicts: []
|
8
|
+
requirements:
|
9
|
+
- name: rdoc
|
10
|
+
version: 3~
|
11
|
+
- name: detroit
|
12
|
+
groups:
|
13
|
+
- build
|
14
|
+
development: true
|
15
|
+
- name: reap
|
16
|
+
groups:
|
17
|
+
- build
|
18
|
+
development: true
|
19
|
+
dependencies: []
|
20
|
+
repositories:
|
21
|
+
- uri: git://github.com/rubyworks/shomen.git
|
22
|
+
scm: git
|
23
|
+
name: upstream
|
24
|
+
resources:
|
25
|
+
home: http://rubyworks.github.com/shomen
|
26
|
+
work: http://github.com/rubyworks/shomen
|
27
|
+
docs: http://github.com/rubyworks/shomen/wiki
|
28
|
+
load_path:
|
29
|
+
- lib
|
30
|
+
extra:
|
31
|
+
manifest: MANIFEST
|
32
|
+
source: []
|
33
|
+
alternatives: []
|
34
|
+
revision: 0
|
35
|
+
name: shomen
|
36
|
+
title: Shomen
|
37
|
+
summary: Standardized Object-Oriented Documentation Model
|
38
|
+
created: '2010-07-01'
|
39
|
+
description: Shomen defines a standard API documentaiton format for object-oriented
|
40
|
+
software (Ruby programs in particular) which can be used by documentation interfaces,
|
41
|
+
e.g. Hypervisor, to render API documentation
|
42
|
+
version: 0.1.0
|
43
|
+
date: '2011-10-05'
|
data/lib/shomen/cli.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Shomen
|
2
|
+
|
3
|
+
# Command line interface. (YARD oriented for now).
|
4
|
+
def self.cli(*argv)
|
5
|
+
case cmd = argv.shift
|
6
|
+
when 'server'
|
7
|
+
require 'shomen/server'
|
8
|
+
when 'tomdoc'
|
9
|
+
require 'shomen/cli/tomdoc'
|
10
|
+
CLI::TomDocCommand.run(*argv)
|
11
|
+
when 'yard'
|
12
|
+
require 'shomen/cli/yard'
|
13
|
+
CLI::YARDCommand.run(*argv)
|
14
|
+
when 'rdoc'
|
15
|
+
require 'shomen/cli/rdoc'
|
16
|
+
CLI::RDocCommand.run(*argv)
|
17
|
+
else
|
18
|
+
abort "error: unrecognized command - #{cmd}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Shomen
|
2
|
+
|
3
|
+
begin; gem 'json'; rescue; end
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'yaml'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
module CLI
|
10
|
+
|
11
|
+
# Command line interface base class.
|
12
|
+
#
|
13
|
+
class Abstract
|
14
|
+
|
15
|
+
#
|
16
|
+
def self.run(*arg)
|
17
|
+
new.run(*argv)
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
def parse(argv, *choices)
|
22
|
+
options = (Hash === choices.last ? choices.pop : {})
|
23
|
+
parser = OptionParser.new
|
24
|
+
|
25
|
+
choices.each do |choice|
|
26
|
+
send("option_#{choice}", parser, options)
|
27
|
+
end
|
28
|
+
option_debug(parser, options)
|
29
|
+
option_warn(parser, options)
|
30
|
+
option_help(parser, options)
|
31
|
+
|
32
|
+
parser.parse!(argv)
|
33
|
+
|
34
|
+
return options
|
35
|
+
end
|
36
|
+
|
37
|
+
=begin
|
38
|
+
#
|
39
|
+
def option_yaml(parser, options)
|
40
|
+
parser.on('-y', '--yaml', 'output YAML instead of JSON') do
|
41
|
+
options[:format] = 'yaml'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
def option_json(parser, options)
|
47
|
+
parser.on('-j', '--json', 'output JSON instead of YAML (default)') do
|
48
|
+
options[:format] = 'json'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
=end
|
52
|
+
|
53
|
+
#
|
54
|
+
def option_format(parser, options)
|
55
|
+
parser.on('-f', '--format NAME') do |format|
|
56
|
+
options[:format] = format
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
def option_source(parser, options)
|
62
|
+
parser.on('-s', '--[no-]source', 'include full source in script documentation') do |bool|
|
63
|
+
Shomen.source = bool
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
def option_force(parser, options)
|
69
|
+
parser.on('-f', '--force') do
|
70
|
+
options[:force] = true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
def option_debug(parser, options)
|
76
|
+
parser.on_tail('-D', '--debug', 'run with $DEBUG set to true') do
|
77
|
+
$DEBUG = true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
def option_warn(parser, options)
|
83
|
+
parser.on_tail('-W', '--warn', 'run with $VERBOSE set to true') do
|
84
|
+
$VERBOSE = true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
def option_help(parser, options)
|
90
|
+
parser.on_tail('--help') do
|
91
|
+
puts opt
|
92
|
+
exit 0
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
def root?
|
98
|
+
root = false
|
99
|
+
root = true if File.exist?('.ruby')
|
100
|
+
root = true if File.exist?('.yardoc')
|
101
|
+
root = true if File.exist?('.git')
|
102
|
+
root = true if File.exist?('.hg')
|
103
|
+
root
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
def self.source?
|
112
|
+
@source
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
def self.source=(bool)
|
117
|
+
@source = bool
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Shomen
|
2
|
+
|
3
|
+
begin; gem 'json'; rescue; end
|
4
|
+
|
5
|
+
require 'shomen/cli/abstract'
|
6
|
+
require 'tmpdir'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
module CLI
|
10
|
+
|
11
|
+
# RDoc command line interface.
|
12
|
+
class RDocCommand < Abstract
|
13
|
+
|
14
|
+
#
|
15
|
+
def self.run(*argv)
|
16
|
+
new.run(argv)
|
17
|
+
end
|
18
|
+
|
19
|
+
# New RDoc command line interface.
|
20
|
+
def initialize
|
21
|
+
begin
|
22
|
+
gem 'rdoc'
|
23
|
+
rescue
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
#
|
28
|
+
def run(argv)
|
29
|
+
require 'shomen/rdoc'
|
30
|
+
|
31
|
+
defaults = {}
|
32
|
+
defaults[:format] = :json
|
33
|
+
defaults[:force] = false
|
34
|
+
defaults[:source] = true
|
35
|
+
|
36
|
+
options = parse(argv, :format, :force, :visibility, :main, :source, defaults)
|
37
|
+
|
38
|
+
if !options[:force] && !root?
|
39
|
+
$stderr.puts "Not a project directory. Use --force to override."
|
40
|
+
exit -1
|
41
|
+
end
|
42
|
+
|
43
|
+
if argv.empty?
|
44
|
+
if File.exist?('.document')
|
45
|
+
files = File.read('.document').split("\n")
|
46
|
+
files = files.reject{ |f| f.strip == '' or f.strip =~ /^\#/ }
|
47
|
+
files = files.map{ |f| Dir[f] }.flatten
|
48
|
+
else
|
49
|
+
files = ['lib']
|
50
|
+
end
|
51
|
+
else
|
52
|
+
files = argv
|
53
|
+
end
|
54
|
+
|
55
|
+
tmpdir = File.join(Dir.tmpdir, 'shomen-rdoc')
|
56
|
+
main = options[:main] || Dir.glob('{README.*,README}').first
|
57
|
+
visibility = options[:visibility].to_s
|
58
|
+
|
59
|
+
# TODO: Any way to supress the cretion of the time stamp altogether?
|
60
|
+
# Options#update_output_dir for instance?
|
61
|
+
|
62
|
+
# TODO: Using the ::RDoc::Options doesn't seem to work.
|
63
|
+
# It complains about a template being nil in `rdoc/options.rb:760`.
|
64
|
+
|
65
|
+
#rdoc_options = ::RDoc::Options.new
|
66
|
+
#rdoc_options.generator = 'shomen'
|
67
|
+
#rdoc_options.main_page = Dir.glob('README*').first
|
68
|
+
##rdoc_options.template = 'shomen'
|
69
|
+
##rdoc_options.template_dir = File.dirname(__FILE__)
|
70
|
+
#rdoc_options.op_dir = 'tmp/rdoc' # '/dev/null'
|
71
|
+
#rdoc_options.files = files
|
72
|
+
|
73
|
+
rdoc_options = []
|
74
|
+
rdoc_options += ['-q']
|
75
|
+
#rdoc_options += ['-t', title]
|
76
|
+
rdoc_options += ['-f', 'shomen']
|
77
|
+
rdoc_options += ['-m', main] if main
|
78
|
+
rdoc_options += ['-V', visibility]
|
79
|
+
rdoc_options += ['-o', tmpdir] # '/dev/null'
|
80
|
+
rdoc_options += files
|
81
|
+
|
82
|
+
rdoc = ::RDoc::RDoc.new
|
83
|
+
rdoc.document(rdoc_options)
|
84
|
+
|
85
|
+
case options[:format]
|
86
|
+
when :yaml
|
87
|
+
$stdout.puts(rdoc.generator.shomen.to_yaml)
|
88
|
+
else
|
89
|
+
$stdout.puts(JSON.generate(rdoc.generator.shomen))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
def option_visibility(parser, options)
|
95
|
+
parser.on('--private', 'include public, protected and private methods') do
|
96
|
+
options[:visibility] = :private
|
97
|
+
end
|
98
|
+
parser.on('--protected', 'include public and protected methods') do
|
99
|
+
options[:visibility] = :protected
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
#
|
104
|
+
#def option_document(parser, options)
|
105
|
+
# parser.on('--document FILE') do |file|
|
106
|
+
# options[:document] = file
|
107
|
+
# end
|
108
|
+
#end
|
109
|
+
|
110
|
+
#
|
111
|
+
def option_main(parser, options)
|
112
|
+
parser.on('-m', '--main FILE') do |file|
|
113
|
+
options[:main] = file
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# TODO: Add support for additional options supported by rdoc.
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|