origen_doc_helpers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/config/application.rb +34 -0
  3. data/config/commands.rb +42 -0
  4. data/config/development.rb +16 -0
  5. data/config/environment.rb +30 -0
  6. data/config/users.rb +19 -0
  7. data/config/version.rb +8 -0
  8. data/lib/helpers.rb +234 -0
  9. data/lib/origen_doc_helpers.rb +2 -0
  10. data/lib/origen_doc_helpers/doc_interface.rb +74 -0
  11. data/lib/origen_doc_helpers/dut.rb +194 -0
  12. data/lib/origen_doc_helpers/pdf.rb +122 -0
  13. data/program/_func.rb +12 -0
  14. data/program/_hvst.rb +12 -0
  15. data/program/_para.rb +26 -0
  16. data/program/probe_1.rb +7 -0
  17. data/templates/pdf/topic_wrapper.html +21 -0
  18. data/templates/shared/_register.html.erb +207 -0
  19. data/templates/shared/_searchable.html.erb +86 -0
  20. data/templates/shared/_spec.html.erb +20 -0
  21. data/templates/shared/test/_flow.md.erb +227 -0
  22. data/templates/web/examples.md.erb +19 -0
  23. data/templates/web/examples/register.md.erb +101 -0
  24. data/templates/web/examples/searchable/intro.md.erb +128 -0
  25. data/templates/web/examples/searchable/page2.md.erb +5 -0
  26. data/templates/web/examples/searchable/topic1/item1.md.erb +5 -0
  27. data/templates/web/examples/searchable/topic1/item2.html.erb +7 -0
  28. data/templates/web/examples/spec.md.erb_NOT_WORKING +42 -0
  29. data/templates/web/examples/test/flow.md.erb +35 -0
  30. data/templates/web/examples/yammer.md.erb +28 -0
  31. data/templates/web/index.md.erb +40 -0
  32. data/templates/web/layouts/_basic.html.erb +13 -0
  33. data/templates/web/layouts/_doc.html.erb +22 -0
  34. data/templates/web/layouts/_examples.html.erb +5 -0
  35. data/templates/web/partials/_navbar.html.erb +21 -0
  36. data/templates/web/release_notes.md.erb +5 -0
  37. metadata +94 -0
@@ -0,0 +1,128 @@
1
+ % render "templates/web/layouts/doc.html", heading: "Creating Searchable Documents" do
2
+
3
+ This helper provides a layout that will create a nested collection of
4
+ documents like this one and which are searchable via the box on the
5
+ top left.
6
+
7
+ %#It can also build a PDF representation of the document collection.
8
+
9
+ ### The Document Index
10
+
11
+ The application must supply a hash to describe the page index that has been built
12
+ on the the left of the page.
13
+ Here is the index used for this page:
14
+
15
+ ~~~ruby
16
+ index = {}
17
+ index[nil] = {
18
+ intro: "Introduction",
19
+ page2: "Page 2",
20
+ }
21
+ index["Topic 1"] = {
22
+ topic1_item1: "First Item",
23
+ topic1_item2: "Second Item",
24
+ }
25
+ ~~~
26
+
27
+ The sub-hash keys describe where each document lives and what its title is, for example
28
+ the document with title "Second Item" should live in <code>_documents_root_/topic1/item2.md.erb</code>.
29
+
30
+ By default the root is <code>"#{Origen.root}/templates/web/docs"</code> but this can be overridden
31
+ by supplying a <code>:root</code> option which should describe the relative path from <code>"#{Origen.root}/templates/web"</code>.
32
+
33
+ ### The Layout Helper
34
+
35
+ A layout helper is provided to include a document in the search and wrap it
36
+ with the indexed layout:
37
+
38
+ ~~~eruby
39
+ <%= "%" %> render "doc_helpers/searchable.html", index: index do
40
+
41
+ Blah blah blah
42
+
43
+ <%= "%" %> end
44
+ ~~~
45
+
46
+ The <code>:index</code> option is mandatory, but the following are optional:
47
+
48
+ ~~~text
49
+ %#:pdf_title - PDF creation is enabled by providing a title via this option, e.g. "My Application Guides"
50
+ :heading - Each wrapped document will have the heading (e.g. "First Item") inserted at the top of the page,
51
+ to override it supply this option. A common example would be if the topic is long and
52
+ so an abbreviated version has been used in the index. e.g. "First Item and Other Stuff"
53
+ :topic - Each wrapped document will have the topic (e.g. "Topic 1") inserted at the top of the page,
54
+ to override it supply this option. A common example would be if the topic is long and
55
+ so an abbreviated version has been used in the index. e.g. "Topic 1 and Other Stuff"
56
+ :root - override the top-level folder containing your documents, e.g. "tutorials/guides"
57
+ :tab - the helper should automatically work out what tab to select for each document, however
58
+ if it is struggling for some reason you can force it by supplying the hash key from the
59
+ index that the given document should be associated with, e.g. :topic1_item1
60
+ ~~~
61
+
62
+ ### Incorporating in Your Own Layout
63
+
64
+ Normally the searchable layout will be wrapped in your own application specific layout
65
+ to insert your custom navigation bar, etc.
66
+
67
+ As an example here is the actual layout that has been used to generate this page:
68
+
69
+
70
+ ~~~eruby
71
+ ---
72
+ title: <%= options[:title] || Origen.config.name %>
73
+ ---
74
+ <%= "<" + "%= render \"partials/navbar.html\", tab: :examples %" + ">" %>
75
+
76
+ <%= "%" %> index = {}
77
+ <%= "%" %> index[nil] = {
78
+ <%= "%" %> intro: "Introduction",
79
+ <%= "%" %> page2: "Page 2",
80
+ <%= "%" %> }
81
+ <%= "%" %> index["Topic 1"] = {
82
+ <%= "%" %> topic1_item1: "First Item",
83
+ <%= "%" %> topic1_item2: "Second Item",
84
+ <%= "%" %> }
85
+
86
+ %#<%= "%" %> opts = options.merge(index: index, root: "examples/searchable", pdf_title: "Doc Helpers Searchable Guide")
87
+ <%= "%" %> opts = options.merge(index: index, root: "examples/searchable")
88
+ <%= "%" %> render "doc_helpers/searchable.html", options.merge(opts) do
89
+
90
+ <%= "<" + "%= yield %" + ">" %>
91
+
92
+ <%= "%" %> end
93
+ ~~~
94
+
95
+ %#### Enabling PDF Generation
96
+ %#
97
+ %#PDF generation is enabled by supplying the <code>:pdf_title</code> option when calling
98
+ %#the <code>searchable.html</code> template as shown above.
99
+ %#No other application-level configuration or setup is required.
100
+ %#
101
+ %#This will generate the PDF at web site deploy time and add the download link to
102
+ %#the searchable document menu.
103
+ %#
104
+ %#PDF generation is currently only supported on Linux/CDE, the same restriction that applies
105
+ %#to deploying a web site.
106
+
107
+ ### Writing Your Documents
108
+
109
+ With the layout setup, writing documents is very simple; these should normally
110
+ be regular markdown that is wrapped in your layout.
111
+
112
+ The top-level header size in your document should be <code>h3</code> or <code>###</code> in markdown.
113
+
114
+ <code>.html.erb</code> files will also work if you want to use them.
115
+
116
+ Here is the actual code used behind the [Topic 1 - First Item](<%= path "examples/searchable/topic1/item1" %>)
117
+ page (where the layout being rendered is the one above):
118
+
119
+
120
+ ~~~eruby
121
+ <%= "%" %> render "templates/web/layouts/doc.html" do
122
+
123
+ Hello I'm item 1
124
+
125
+ <%= "%" %> end
126
+ ~~~
127
+
128
+ % end
@@ -0,0 +1,5 @@
1
+ % render "templates/web/layouts/doc.html" do
2
+
3
+ Hello I'm page 2 of the searchable content!
4
+
5
+ % end
@@ -0,0 +1,5 @@
1
+ % render "templates/web/layouts/doc.html" do
2
+
3
+ Hello I'm item 1
4
+
5
+ % end
@@ -0,0 +1,7 @@
1
+ % render "templates/web/layouts/doc.html" do
2
+
3
+ <p>
4
+ Hello I'm item 2, blah blah blah
5
+ </p>
6
+
7
+ % end
@@ -0,0 +1,42 @@
1
+ % render "../layouts/examples.html" do
2
+
3
+ # Specification Helpers
4
+
5
+ Use the [Origen specification API](http://origen.freescale.net/origen/latest/guides/models/specs)
6
+ to define specifications in the normal way,
7
+ all of the examples shown here are based on this specification definition:
8
+
9
+ ~~~ruby
10
+ spec :soc_vdd do
11
+ symbol "Vdd"
12
+ description "Soc Core Power Supply"
13
+ min "#{vdd_nom} - 50.mV"
14
+ max "#{vdd_nom} + 50.mV"
15
+ audience :external
16
+ end
17
+ ~~~
18
+
19
+ ### Specification Table
20
+
21
+ <%= render "templates/shared/spec", spec: $dut.specs %>
22
+
23
+ Users can pass the following objects as arguments to the spec option:
24
+
25
+ 1. An object that contains specs (e.g. $dut)
26
+ 2. An object's spec hash (e.g. $dut.specs)
27
+ 3. An individual spec (e.g. $dut.specs(:soc_vdd))
28
+
29
+ Here is an example of how to insert a specification table in
30
+ a document using method #3 from above:
31
+
32
+ ~~~eruby
33
+ ## Specification Table
34
+
35
+ <%= "%" %> $dut.specs.each do |name, spec|
36
+
37
+ <%= "<" + "%= render \"doc_helpers/spec.html\", spec: spec %" + ">" %>
38
+
39
+ <%= "%" %> end
40
+ ~~~
41
+
42
+ % end
@@ -0,0 +1,35 @@
1
+ % render "../../layouts/examples.html" do
2
+
3
+ # Test Flow
4
+
5
+ Documentation of an Origen-generated test program can be created as follows (requires a
6
+ documentation interface to be setup):
7
+
8
+ ~~~eruby
9
+ <%= "%" %> prog = Origen::Tester::Doc.generate_program_model("program/probe_1.rb", :target => "default")
10
+
11
+ <%= "<" + "%= render \"doc_helpers/test/flow.md\", :heading => \"Probe 1\", :program => prog, :flow => :probe_1_flow %" + ">" %>
12
+ ~~~
13
+
14
+ The test flow helper takes the following required options:
15
+
16
+ * **heading** - The page heading, generally the name of the flow
17
+ * **program** - Supply a pre-generated program model
18
+ * **flow(s)** - The name of the flow(s) to document, supply multiple in an array
19
+
20
+ Additionally these options are available to customize the output:
21
+
22
+ * **link_to_pattern_docs** - Set this to <code>true</code> to generate links to documentation of the patterns
23
+ in place of the pattern name. Pattern docs should be placed in <code>templates/web/patterns</code> and the
24
+ files should be called \<pattern_name\>.md
25
+ * **context** - Supply an execution context to document only the test where the context is true. For example to
26
+ document the tests that will run when job is "P1"is set
27
+ supply <code>{ :job => "P1" }</code>
28
+
29
+ Here is a live example:
30
+
31
+ % prog = Origen::Tester::Doc.generate_program_model("program/probe_1.rb", :target => "debug")
32
+
33
+ <%= render "templates/shared/test/flow.md", :heading => "Probe 1", :program => prog, :flow => :probe_1_flow %>
34
+
35
+ % end
@@ -0,0 +1,28 @@
1
+ % render "../layouts/examples.html" do
2
+
3
+ # Yammer Widgets
4
+
5
+ These helpers wrap the [Yammer Embed API](https://developer.yammer.com/connect/)
6
+ which allows Yammer feeds to be embedded in any web page.
7
+
8
+ The most useful application of this is to provide a comment stream which will be
9
+ unique to each page, like the one you see below!
10
+
11
+ To include comments simply add this to the bottom of any given page, or your
12
+ layout file to add comments to every page:
13
+
14
+ ~~~eruby
15
+ <%= "<" + "%= yammer_comments %" + ">" %>
16
+ ~~~
17
+
18
+ The following options are available:
19
+
20
+ ~~~text
21
+ :prompt - Set what the prompt for new comments should be, 'Comment on this page' is the default
22
+ :group_id - Specify a specific Yammer group ID, defaults to config.yammer_group in the application config, and if not defined falls back to the
23
+ Origen User's Group
24
+ ~~~
25
+
26
+ <%= yammer_comments %>
27
+
28
+ % end
@@ -0,0 +1,40 @@
1
+ % render "layouts/basic.html" do
2
+
3
+ %# HTML tags can be embedded in mark down files if you want to do specific custom
4
+ %# formatting like this, but in most cases that is not required.
5
+ <h1><%= Origen.config.name %> <span style="font-size: 14px">(<%= Origen.app.version %>)</span></h1>
6
+
7
+ ### Purpose
8
+
9
+ This plugin contains a collection of pre-written documentation layouts and helpers for use in
10
+ many typical Origen documentation scenarios.
11
+
12
+ Additional contributions are welcome, see below for how to setup a development environment,
13
+ please add examples for any new features.
14
+
15
+ ### How To Import
16
+
17
+ In your Gemfile add:
18
+
19
+ ~~~ruby
20
+ gem "origen_doc_helpers", ">= <%= Origen.app.version %>"
21
+ ~~~
22
+
23
+ or if your application is a plugin add this to your <code>.gemspec</code>
24
+
25
+ ~~~ruby
26
+ spec.add_development_dependency "origen_doc_helpers", ">= <%= Origen.app.version %>"
27
+ ~~~
28
+
29
+ ### How To Use
30
+
31
+ See the [Examples](<%= path "examples" %>) to see what is available
32
+ and how to use them.
33
+
34
+ ### How To Setup a Development Environment
35
+
36
+ [Clone the repository from Github](https://github.com/Origen-SDK/origen_doc_helpers).
37
+
38
+ All templates can be found in <code>templates/shared</code>.
39
+
40
+ % end
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: <%= options[:title] || Origen.config.name %>
3
+ ---
4
+ <%= render "templates/web/partials/navbar.html", :tab => options[:tab] %>
5
+
6
+ <div class="row">
7
+ %# The markdown attribute is important if you are going to include content written
8
+ %# in markdown, without this is will be included verbatim
9
+ <div class="span12" markdown="1">
10
+ <%= yield %>
11
+
12
+ </div>
13
+ </div>
@@ -0,0 +1,22 @@
1
+ ---
2
+ title: <%= options[:title] || Origen.config.name %>
3
+ ---
4
+ <%= render "partials/navbar.html", :tab => :examples %>
5
+
6
+ %# Add/edit sections here, the code below will expand this with the correct markup,
7
+ %# pass in the topic you want selected via the :tab option.
8
+ % s = {}
9
+ % s[nil] = {
10
+ % :intro => "Introduction",
11
+ % :page2 => "Page 2",
12
+ % }
13
+ % s["Topic 1"] = {
14
+ % :topic1_item1 => "First Item",
15
+ % :topic1_item2 => "Second Item",
16
+ % }
17
+
18
+ % render "templates/shared/searchable.html", options.merge(:index => s, :root => "examples/searchable") do
19
+
20
+ <%= yield %>
21
+
22
+ % end
@@ -0,0 +1,5 @@
1
+ % render "basic.html", :tab => :examples do
2
+
3
+ <%= yield %>
4
+
5
+ % end
@@ -0,0 +1,21 @@
1
+ <nav class="navbar navbar-inverse navbar-fixed-top">
2
+ <div class="container">
3
+ <div class="navbar-header">
4
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
5
+ <span class="sr-only">Toggle navigation</span>
6
+ <span class="icon-bar"></span>
7
+ <span class="icon-bar"></span>
8
+ <span class="icon-bar"></span>
9
+ </button>
10
+ <a class="navbar-brand" href="<%= path "/" %>">Home</a>
11
+ </div>
12
+ <div id="navbar" class="collapse navbar-collapse">
13
+ <ul class="nav navbar-nav">
14
+ <li class="<%= options[:tab] == :examples ? 'active' : '' %>"><a href="<%= path "/examples" %>">Examples</a></li>
15
+ <li class="<%= options[:tab] == :release ? 'active' : '' %>"><a href="<%= path "/release_notes" %>">Release Notes</a></li>
16
+ <li><a href="https://github.com/Origen-SDK/origen_doc_helpers">Github</a></li>
17
+ </ul>
18
+ <%= import "origen/web/logo.html" %>
19
+ </div><!--/.nav-collapse -->
20
+ </div>
21
+ </nav>
@@ -0,0 +1,5 @@
1
+ % render "layouts/basic.html", :tab => :release do
2
+
3
+ <%= render "#{Origen.root}/doc/history" %>
4
+
5
+ % end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: origen_doc_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephen McGinty
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: origen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.5
27
+ description:
28
+ email:
29
+ - stephen.f.mcginty@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - config/application.rb
35
+ - config/commands.rb
36
+ - config/development.rb
37
+ - config/environment.rb
38
+ - config/users.rb
39
+ - config/version.rb
40
+ - lib/helpers.rb
41
+ - lib/origen_doc_helpers.rb
42
+ - lib/origen_doc_helpers/doc_interface.rb
43
+ - lib/origen_doc_helpers/dut.rb
44
+ - lib/origen_doc_helpers/pdf.rb
45
+ - program/_func.rb
46
+ - program/_hvst.rb
47
+ - program/_para.rb
48
+ - program/probe_1.rb
49
+ - templates/pdf/topic_wrapper.html
50
+ - templates/shared/_register.html.erb
51
+ - templates/shared/_searchable.html.erb
52
+ - templates/shared/_spec.html.erb
53
+ - templates/shared/test/_flow.md.erb
54
+ - templates/web/examples.md.erb
55
+ - templates/web/examples/register.md.erb
56
+ - templates/web/examples/searchable/intro.md.erb
57
+ - templates/web/examples/searchable/page2.md.erb
58
+ - templates/web/examples/searchable/topic1/item1.md.erb
59
+ - templates/web/examples/searchable/topic1/item2.html.erb
60
+ - templates/web/examples/spec.md.erb_NOT_WORKING
61
+ - templates/web/examples/test/flow.md.erb
62
+ - templates/web/examples/yammer.md.erb
63
+ - templates/web/index.md.erb
64
+ - templates/web/layouts/_basic.html.erb
65
+ - templates/web/layouts/_doc.html.erb
66
+ - templates/web/layouts/_examples.html.erb
67
+ - templates/web/partials/_navbar.html.erb
68
+ - templates/web/release_notes.md.erb
69
+ homepage: http://origen-sdk.org/doc_helpers
70
+ licenses:
71
+ - LGPL-3
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 1.9.3
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 1.8.11
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.2.2
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Snippets and helpers for creating Origen web documents
93
+ test_files: []
94
+ has_rdoc: