origen_doc_helpers 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/config/boot.rb +19 -0
  3. data/config/version.rb +1 -1
  4. data/lib/origen_doc_helpers.rb +21 -1
  5. data/lib/origen_doc_helpers/flow_page_generator.rb +110 -0
  6. data/lib/{helpers.rb → origen_doc_helpers/helpers.rb} +0 -0
  7. data/lib/origen_doc_helpers/model_page_generator.rb +151 -0
  8. data/templates/flow_index.md.erb +19 -0
  9. data/templates/flow_page.md.erb +4 -0
  10. data/templates/model_index.md.erb +24 -0
  11. data/templates/model_page.md.erb +125 -0
  12. data/templates/shared/_register.html.erb +51 -7
  13. data/templates/shared/_searchable.html.erb +1 -1
  14. data/templates/shared/test/_flow.md.erb +3 -230
  15. data/templates/web/helpers.md.erb +25 -0
  16. data/templates/web/{examples → helpers}/disqus.md.erb +3 -3
  17. data/templates/web/helpers/flow.md.erb +113 -0
  18. data/templates/web/helpers/model.md.erb +81 -0
  19. data/templates/web/{examples → helpers}/register.md.erb +5 -5
  20. data/templates/web/{examples → helpers}/searchable/intro.md.erb +4 -4
  21. data/templates/web/{examples → helpers}/searchable/page2.md.erb +0 -0
  22. data/templates/web/{examples → helpers}/searchable/topic1/item1.md.erb +0 -0
  23. data/templates/web/{examples → helpers}/searchable/topic1/item2.html.erb +0 -0
  24. data/templates/web/{examples → helpers}/spec.md.erb_NOT_WORKING +2 -2
  25. data/templates/web/{examples → helpers}/yammer.md.erb +1 -1
  26. data/templates/web/index.md.erb +1 -1
  27. data/templates/web/layouts/_doc.html.erb +2 -2
  28. data/templates/web/layouts/{_examples.html.erb → _helpers.html.erb} +1 -1
  29. data/templates/web/partials/_navbar.html.erb +1 -1
  30. metadata +27 -26
  31. data/config/development.rb +0 -16
  32. data/config/environment.rb +0 -32
  33. data/lib/origen_doc_helpers/doc_interface.rb +0 -74
  34. data/program/_func.rb +0 -12
  35. data/program/_hvst.rb +0 -12
  36. data/program/_para.rb +0 -26
  37. data/program/probe_1.rb +0 -7
  38. data/templates/web/examples.md.erb +0 -20
  39. data/templates/web/examples/test/flow.md.erb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee3e3f947570dd8db7cd7eeca0321269b048e832
4
- data.tar.gz: 3674401952587d0d7a14421b205935b6dcafc44b
3
+ metadata.gz: 25148e1c8c40efe62a9f793aa7df9281ce5b7e07
4
+ data.tar.gz: 4318d42ec7a1aaae0007e8dd37adcec8f1eaa5a5
5
5
  SHA512:
6
- metadata.gz: 2999b9c681e79d2625cb9c4f2c1eccda196573d7a68357d29adad24a25a34cd4d577541d26bef76932ab6d9b4e4ee46f38112973f480cc745b1690e88acd92ee
7
- data.tar.gz: bb1b457ffa445709a35f91a05f8d0181c4cab356cbde177dfb803193ec2e5c8dac87ef8b51281be56fbdb4a4dccd11207ca65434e20085f1977f8f12a8f4de74
6
+ metadata.gz: 526bcb1a4d23c2662ec7b037bae220e6387739e135f8a90a6188ba0e36a387003f1767c825c5e591fe70b43ea0cf03170760de195f089758b3422d734c4bf559
7
+ data.tar.gz: fd4d0f42ffddda0e4eb8a17d6c69b4b080dea33cdffdf740bf2644405ae97e8c235e2589e8bae90842dfb9d623674ff9e2af70c9363399abb6c054532b989623
data/config/boot.rb ADDED
@@ -0,0 +1,19 @@
1
+ # This file is used to boot your plugin when it is running in standalone mode
2
+ # from its own workspace - i.e. when the plugin is being developed.
3
+ #
4
+ # It will not be loaded when the plugin is imported by a 3rd party app - in that
5
+ # case only lib/origen_doc_helpers.rb is loaded.
6
+ #
7
+ # Therefore this file can be used to load anything extra that you need to boot
8
+ # the development environment for this app. For example this is typically used
9
+ # to load some additional test classes to use your plugin APIs so that they can
10
+ # be tested and/or interacted with in the console.
11
+ require "origen_doc_helpers"
12
+
13
+ # Load a Top-level/DUT class that is defined within this plugin's lib directory
14
+ # and is required by some of our tests.
15
+ # Normally such a class should not be exposed to 3rd party users of the plugin,
16
+ # so we required it here rather than in lib/origen_doc_helpers.rb.
17
+ module OrigenDocHelpers
18
+ autoload :DUT, "origen_doc_helpers/dut"
19
+ end
data/config/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module OrigenDocHelpers
2
2
  MAJOR = 0
3
- MINOR = 3
3
+ MINOR = 4
4
4
  BUGFIX = 0
5
5
  DEV = nil
6
6
 
@@ -1,2 +1,22 @@
1
+ require 'origen'
1
2
  require_relative '../config/application.rb'
2
- require_relative '../config/environment.rb'
3
+
4
+ module OrigenDocHelpers
5
+ autoload :PDF, 'origen_doc_helpers/pdf'
6
+ autoload :HtmlFlowFormatter, 'origen_doc_helpers/html_flow_formatter'
7
+ autoload :ListFlowFormatter, 'origen_doc_helpers/list_flow_formatter'
8
+ autoload :FlowPageGenerator, 'origen_doc_helpers/flow_page_generator'
9
+ autoload :ModelPageGenerator, 'origen_doc_helpers/model_page_generator'
10
+ end
11
+
12
+ require 'origen_doc_helpers/helpers'
13
+
14
+ module OrigenDocHelpers
15
+ def self.generate_flow_docs(options = {}, &block)
16
+ FlowPageGenerator.run(options, &block)
17
+ end
18
+
19
+ def self.generate_model_docs(options = {}, &block)
20
+ ModelPageGenerator.run(options, &block)
21
+ end
22
+ end
@@ -0,0 +1,110 @@
1
+ module OrigenDocHelpers
2
+ class FlowPageGenerator
3
+ class << self
4
+ attr_accessor :layout_options
5
+ attr_accessor :layout
6
+ attr_reader :pages
7
+
8
+ def run(options)
9
+ @pages = {}
10
+ unless options[:layout]
11
+ fail 'You must pass a :layout option providing an absolute path to the layout file to be used'
12
+ end
13
+ unless File.exist?(options[:layout].to_s)
14
+ fail "This layout file does not exist: #{options[:layout]}"
15
+ end
16
+ self.layout = options.delete(:layout)
17
+ self.layout_options = options
18
+ yield self
19
+ write_index unless @pages.size == 0
20
+ @pages = nil
21
+ end
22
+
23
+ def page(options)
24
+ if !options[:name] || !(options[:flow] || options[:flows]) ||
25
+ !options[:target]
26
+ fail 'The following options are required: :name, :flow(s), :target'
27
+ end
28
+ p = new(options)
29
+ pages[options[:group]] ||= []
30
+ pages[options[:group]] << p
31
+ p.run
32
+ end
33
+
34
+ def write_index
35
+ f = "#{Origen.root}/web/content/flows.md"
36
+ Origen.log.info "Building flow index page: #{f}"
37
+ t = Origen.compile index_page_template,
38
+ layout: layout,
39
+ layout_options: layout_options,
40
+ no_group_pages: pages.delete(nil),
41
+ pages: pages
42
+
43
+ File.write(f, t)
44
+ end
45
+
46
+ def index_page_template
47
+ @index_page_template ||= "#{Origen.root!}/templates/flow_index.md.erb"
48
+ end
49
+ end
50
+
51
+ def initialize(options)
52
+ @options = options
53
+ end
54
+
55
+ def run
56
+ Origen.log.info "Building flow page: #{output_file}"
57
+ t = Origen.compile flow_page_template,
58
+ layout: self.class.layout,
59
+ layout_options: self.class.layout_options,
60
+ flow_template: flow_template,
61
+ heading: heading,
62
+ target: @options[:target],
63
+ flows: [@options[:flows] || @options[:flow]].flatten,
64
+ context: @options[:context] || {}
65
+ File.write(output_file, t)
66
+ end
67
+
68
+ def name
69
+ @options[:name]
70
+ end
71
+
72
+ def heading
73
+ if @options[:group]
74
+ @options[:group] + ': ' + @options[:name]
75
+ else
76
+ @options[:name]
77
+ end
78
+ end
79
+
80
+ def output_file
81
+ f = @options[:name].to_s.symbolize
82
+ "#{output_dir}/#{f}.md"
83
+ end
84
+
85
+ def output_path
86
+ p = 'flows'
87
+ if @options[:group]
88
+ p += ('/' + @options[:group].to_s.symbolize.to_s)
89
+ end
90
+ p + '/' + @options[:name].to_s.symbolize.to_s
91
+ end
92
+
93
+ def output_dir
94
+ d = "#{Origen.root}/web/content/flows"
95
+ if @options[:group]
96
+ d += ('/' + @options[:group].to_s.symbolize.to_s)
97
+ end
98
+ FileUtils.mkdir_p(d) unless File.exist?(d)
99
+ d
100
+ end
101
+
102
+ def flow_page_template
103
+ @flow_page_template ||= "#{Origen.root!}/templates/flow_page.md.erb"
104
+ end
105
+
106
+ def flow_template
107
+ @flow_template ||= "#{Origen.root!}/templates/shared/test/_flow.md.erb"
108
+ end
109
+ end
110
+ end
File without changes
@@ -0,0 +1,151 @@
1
+ module OrigenDocHelpers
2
+ class ModelPageGenerator
3
+ class << self
4
+ attr_accessor :layout_options
5
+ attr_accessor :layout
6
+ attr_reader :pages
7
+
8
+ def run(options)
9
+ @pages = {}
10
+ unless options[:layout]
11
+ fail 'You must pass a :layout option providing an absolute path to the layout file to be used'
12
+ end
13
+ unless File.exist?(options[:layout].to_s)
14
+ fail "This layout file does not exist: #{options[:layout]}"
15
+ end
16
+ self.layout = options.delete(:layout)
17
+ self.layout_options = options
18
+ yield self
19
+ write_index unless @pages.size == 0
20
+ @pages = nil
21
+ end
22
+
23
+ def page(options)
24
+ unless options[:model]
25
+ fail 'The following options are required: :model'
26
+ end
27
+ p = new(options)
28
+ pages[options[:group]] ||= []
29
+ pages[options[:group]] << p
30
+ p.run
31
+ end
32
+
33
+ def write_index
34
+ f = "#{Origen.root}/web/content/models.md"
35
+ Origen.log.info "Building models index page: #{f}"
36
+ t = Origen.compile index_page_template,
37
+ layout: layout,
38
+ layout_options: layout_options,
39
+ no_group_pages: pages.delete(nil),
40
+ pages: pages
41
+
42
+ File.write(f, t)
43
+ end
44
+
45
+ def index_page_template
46
+ @index_page_template ||= "#{Origen.root!}/templates/model_index.md.erb"
47
+ end
48
+ end
49
+
50
+ attr_reader :model
51
+
52
+ def initialize(options)
53
+ @options = options
54
+ @model = options[:model]
55
+ end
56
+
57
+ def run
58
+ create_page(@model, top: true, breadcrumbs: [['Top', output_path]], path: output_path, origen_path: '')
59
+ end
60
+
61
+ def create_page(model, options = {})
62
+ output_file = "#{Origen.root}/web/content/#{options[:path]}.md"
63
+
64
+ Origen.log.info "Building model page: #{output_file}"
65
+ t = Origen.compile model_page_template,
66
+ layout: self.class.layout,
67
+ layout_options: self.class.layout_options,
68
+ heading: heading,
69
+ search_id: search_id,
70
+ model: model,
71
+ breadcrumbs: options[:breadcrumbs],
72
+ path: options[:path],
73
+ origen_path: options[:origen_path]
74
+
75
+ write_out(output_file, t)
76
+
77
+ model.sub_blocks.each do |name, block|
78
+ path = options[:path] + "/#{name}"
79
+ if options[:origen_path].empty?
80
+ origen_path = name.to_s
81
+ else
82
+ origen_path = options[:origen_path] + ".#{name}"
83
+ end
84
+ create_page block,
85
+ breadcrumbs: options[:breadcrumbs] + [[name, path]],
86
+ path: path,
87
+ origen_path: origen_path
88
+ end
89
+ end
90
+
91
+ def write_out(file, content)
92
+ d = Pathname.new(file).dirname.to_s
93
+ FileUtils.mkdir_p(d) unless File.exist?(d)
94
+
95
+ yaml = ''
96
+ # Remove any frontmatter inherited from the caller's layout, this is being done via disk for
97
+ # large files due to previous issues with sub'ing on large files that contain many registers
98
+ File.open(file, 'w') do |f|
99
+ frontmatter_done = false
100
+ frontmatter_open = false
101
+ content.each_line do |line|
102
+ if frontmatter_done
103
+ f.puts line
104
+ elsif frontmatter_open
105
+ if line =~ /^\s*---\s*$/
106
+ frontmatter_done = true
107
+ else
108
+ yaml += line
109
+ end
110
+ else
111
+ if line =~ /^\s*---\s*$/
112
+ frontmatter_open = true
113
+ elsif !line.strip.empty?
114
+ frontmatter_done = true
115
+ end
116
+ end
117
+ end
118
+ end
119
+
120
+ # Write out an attribute file containing the search ID to pass it to nanoc
121
+ yaml += "search_id: model_#{id}"
122
+ File.write(file.sub(/\.[^\.]*$/, '.yaml'), yaml)
123
+ end
124
+
125
+ # Returns a Pathname to a uniquely named temporary file
126
+ def temporary_file
127
+ # Ensure this is unique so that is doesn't clash with parallel compile processes
128
+ Pathname.new "#{Origen.root}/tmp/model_#{id}_compiler_#{Process.pid}_#{Time.now.to_f}"
129
+ end
130
+
131
+ def search_id
132
+ "model_#{id}"
133
+ end
134
+
135
+ def id
136
+ @id ||= model.class.to_s.symbolize.to_s.gsub('::', '_')
137
+ end
138
+
139
+ def heading
140
+ model.class.to_s
141
+ end
142
+
143
+ def output_path
144
+ "models/#{id}"
145
+ end
146
+
147
+ def model_page_template
148
+ @model_page_template ||= "#{Origen.root!}/templates/model_page.md.erb"
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,19 @@
1
+ % opts = options
2
+ % render options[:layout], options[:layout_options] do
3
+
4
+ # Test Program Flows
5
+
6
+ % (opts[:no_group_pages] || []).each do |page|
7
+ * [<%= page.name %>](<%= path page.output_path %>)
8
+ % end
9
+
10
+ % (opts[:pages] || {}).each do |group, pages|
11
+ ### <%= group %>
12
+
13
+ % pages.each do |page|
14
+ * [<%= page.name %>](<%= path page.output_path %>)
15
+ % end
16
+
17
+ % end
18
+
19
+ % end
@@ -0,0 +1,4 @@
1
+ % opts = options
2
+ % render options[:layout], options[:layout_options] do
3
+ <%= render opts[:flow_template], heading: opts[:heading], target: opts[:target], flow: opts[:flows], context: opts[:context] %>
4
+ % end
@@ -0,0 +1,24 @@
1
+ % opts = options
2
+ % render options[:layout], options[:layout_options] do
3
+
4
+ <div class="row" style="margin-top: 10px; margin-bottom: 15px;">
5
+ <div class="col-md-9">
6
+ <img src="http://origen-sdk.org/img/origen-device.png" style="float: left; height:50px; width: 50px; margin-top: 14px;">
7
+ <h1 style="float: left; margin-left: 10px;">Models</h1>
8
+ </div>
9
+ </div>
10
+
11
+ % (opts[:no_group_pages] || []).each do |page|
12
+ * [<%= page.heading %>](<%= path page.output_path %>)
13
+ % end
14
+
15
+ % (opts[:pages] || {}).each do |group, pages|
16
+ ### <%= group %>
17
+
18
+ % pages.each do |page|
19
+ * [<%= page.heading %>](<%= path page.output_path %>)
20
+ % end
21
+
22
+ % end
23
+
24
+ % end
@@ -0,0 +1,125 @@
1
+ % opts = options
2
+ % model = options[:model]
3
+ % render options[:layout], options[:layout_options] do
4
+
5
+ <script type="text/javascript">
6
+ // Modified from: http://jsfiddle.net/jhfrench/mc4Qd/
7
+ window.onload = function() {
8
+ // Links to the top of the page
9
+ $('.top-link').click(function() {
10
+ jQuery('html,body').animate({scrollTop: 0}, 500);
11
+ return false;
12
+ });
13
+ };
14
+ </script>
15
+
16
+ <style>
17
+ tr.clickable td { padding: 0px !important; }
18
+ tr.clickable a { display: block; height: 100%; width: 100%; padding: 8px; text-decoration: none; }
19
+ </style>
20
+
21
+ <div class="row" style="margin-top: 10px; margin-bottom: 15px;">
22
+ <div class="col-md-9">
23
+ <img src="http://origen-sdk.org/img/origen-device.png" style="float: left; height:50px; width: 50px; margin-top: 14px;">
24
+ <h1 style="float: left; margin-left: 10px;"><%= opts[:heading] %></h1>
25
+ </div>
26
+ <div id="search" class="col-md-3" style="margin-top: 20px;">
27
+ <form style="margin-bottom: 15px;">
28
+ <div class="input-group">
29
+ <input class="form-control" type="search" placeholder="Search within this model..."/>
30
+ <span class="input-group-btn">
31
+ <button type="submit" class="btn btn-search">GO!</button>
32
+ </span>
33
+ </div>
34
+ </form>
35
+ </div>
36
+ </div>
37
+
38
+ <div class="row">
39
+ <div class="col-md-12">
40
+ <ol class="breadcrumb">
41
+ % size = opts[:breadcrumbs].size
42
+ % opts[:breadcrumbs].each_with_index do |crumb, i|
43
+ % if i == size - 1
44
+ <li class="active"><%= crumb[0] %></li>
45
+ % else
46
+ <li><a href="<%= path crumb[1] %>"><%= crumb[0] %></a></li>
47
+ % end
48
+ % end
49
+ </ol>
50
+ </div>
51
+ </div>
52
+
53
+ <div class="row">
54
+ <div class="col-md-12 search-results">
55
+ </div>
56
+ </div>
57
+
58
+ <div class="row">
59
+ <div class="col-md-6">
60
+ <h3>Blocks</h3>
61
+
62
+ <table class="table table-hover">
63
+ <thead><tr>
64
+ <th>Address</th>
65
+ <th>Name</th>
66
+ </tr></thead>
67
+ <tbody>
68
+ % model.sub_blocks.sort_by { |name, block| block.base_address }.each do |name, block|
69
+ <tr class="clickable">
70
+ <td><a href="<%= path "#{opts[:path]}/#{name}" %>"><%= block.base_address.to_hex %></a></td>
71
+ <td><a href="<%= path "#{opts[:path]}/#{name}" %>"><%= name %></a></td>
72
+ </tr>
73
+ % end
74
+ </tbody>
75
+ </table>
76
+ </div>
77
+
78
+ <div class="col-md-6">
79
+ <h3>Registers</h3>
80
+
81
+ <table class="table table-hover">
82
+ <thead><tr>
83
+ <th>Address</th>
84
+ <th>Name</th>
85
+ </tr></thead>
86
+ <tbody>
87
+ % model.regs.sort_by { |name, reg| reg.offset }.each do |name, reg|
88
+ <tr class="clickable">
89
+ <td><a href="#<%= reg.name %>"><%= reg.address.to_hex %></a></td>
90
+ <td><a href="#<%= reg.name %>"><%= name %></a></td>
91
+ </tr>
92
+ % end
93
+ </tbody>
94
+ </table>
95
+ </div>
96
+ </div>
97
+
98
+
99
+ % if model.owns_registers?
100
+
101
+ <hr>
102
+ <div class="row">
103
+ <div class="col-md-12">
104
+ <article>
105
+ <h3>Registers of <%= model.model.class%> <%= model.name ? "(#{model.name})" : model.try(:includes_origen_top_level?) ? "(dut)" : "" %></h3>
106
+
107
+ % model.regs.sort_by { |name, reg| reg.offset }.each do |name, reg|
108
+
109
+ <div>
110
+ <span class="pull-right"><a class="top-link" href="#">back to top</a></span>
111
+ </div>
112
+
113
+ <%= render "doc_helpers/register.html", reg: reg, preserve_target: true, descriptions: true, origen_path: opts[:origen_path] %>
114
+
115
+ % end
116
+
117
+ </article>
118
+ </div>
119
+ </div>
120
+
121
+ % end
122
+
123
+ % end
124
+ <script>window.origen_search_id = "<%= opts[:search_id] %>";</script>
125
+ <script src="<%= path "search.js" %>"></script>