Module: Udb::Helpers::TemplateHelpers
- Includes:
- WavedromUtil
- Defined in:
- lib/udb_helpers/backend_helpers.rb
Instance Method Summary collapse
-
#anchor_for_non_isa_spec(name) ⇒ String
An anchor for a UDB non-ISA specification documentation.
-
#anchor_for_udb_doc_cov_pt(org, id) ⇒ String
Have to use [[anchor]] instead of [#anchor] since only the former works when in a table cell.
-
#anchor_for_udb_doc_csr(name) ⇒ String
An anchor for UDB CSR documentation.
-
#anchor_for_udb_doc_csr_field(csr_name, field_name) ⇒ String
An anchor for UDB CSR field documentation.
-
#anchor_for_udb_doc_ext(ext_name) ⇒ String
An anchor for UDB extension documentation.
-
#anchor_for_udb_doc_ext_param(ext_name, param_name) ⇒ String
An anchor for UDB parameter documentation.
-
#anchor_for_udb_doc_idl_func(name) ⇒ String
An anchor for an IDL function documentation.
-
#anchor_for_udb_doc_inst(name) ⇒ String
An anchor for UDB instruction documentation.
-
#anchor_for_udb_doc_mmr(name) ⇒ String
An anchor for UDB MMR documentation.
-
#anchor_for_udb_doc_mmr_field(mmr_name, field_name) ⇒ String
An anchor for UDB MMR field documentation.
-
#anchor_inside_idl_inst_code(inst_name, id) ⇒ String
An anchor inside IDL instruction code.
-
#link_into_idl_inst_code(inst_name, id) ⇒ String
A hyperlink into IDL instruction code.
-
#link_to_udb_doc_cov_pt(org, id) ⇒ String
A hyperlink to a UDB certification normative rule (separate chapters for cov pts and test procs).
-
#link_to_udb_doc_csr(csr_name) ⇒ String
A hyperlink to UDB CSR documentation.
-
#link_to_udb_doc_csr_field(csr_name, field_name) ⇒ String
A hyperlink to UDB CSR field documentation.
-
#link_to_udb_doc_ext(ext_name) ⇒ String
A hyperlink to UDB extension documentation.
-
#link_to_udb_doc_ext_param(ext_name, param_name, link_text) ⇒ String
A hyperlink to UDB parameter documentation.
-
#link_to_udb_doc_idl_func(func_name) ⇒ String
A hyperlink to UDB IDL function documentation.
-
#link_to_udb_doc_inst(inst_name) ⇒ String
A hyperlink to UDB instruction documentation.
-
#link_to_udb_doc_mmr(mmr_name) ⇒ String
A hyperlink to UDB MMR documentation.
-
#link_to_udb_doc_mmr_field(mmr_name, field_name) ⇒ String
A hyperlink to UDB MMR field documentation.
-
#partial(template_pname, inputs = {}) ⇒ String
Include a partial ERB template into a full ERB template.
Methods included from WavedromUtil
#fix_entities, #json_dump_with_hex_literals, #process_wavedrom
Instance Method Details
#anchor_for_non_isa_spec(name) ⇒ String
Returns An anchor for a UDB non-ISA specification documentation.
266 267 268 |
# File 'lib/udb_helpers/backend_helpers.rb', line 266 def anchor_for_non_isa_spec(name) "[[udb:doc:non_isa:#{name.sanitize}]]" end |
#anchor_for_udb_doc_cov_pt(org, id) ⇒ String
Have to use [[anchor]] instead of [#anchor] since only the former works when in a table cell.
259 260 261 262 |
# File 'lib/udb_helpers/backend_helpers.rb', line 259 def anchor_for_udb_doc_cov_pt(org, id) raise ArgumentError, "Unknown org value of '#{org}' for ID '#{id}'" unless org == "sep" || org == "combo" || org == "appendix" "[[udb:doc:cov_pt:#{org}:#{id.sanitize}]]" end |
#anchor_for_udb_doc_csr(name) ⇒ String
Returns An anchor for UDB CSR documentation.
225 226 227 |
# File 'lib/udb_helpers/backend_helpers.rb', line 225 def anchor_for_udb_doc_csr(name) "[#udb:doc:csr:#{name.sanitize}]" end |
#anchor_for_udb_doc_csr_field(csr_name, field_name) ⇒ String
Returns An anchor for UDB CSR field documentation.
232 233 234 |
# File 'lib/udb_helpers/backend_helpers.rb', line 232 def anchor_for_udb_doc_csr_field(csr_name, field_name) "[#udb:doc:csr_field:#{csr_name.sanitize}:#{field_name.sanitize}]" end |
#anchor_for_udb_doc_ext(ext_name) ⇒ String
Returns An anchor for UDB extension documentation.
205 206 207 |
# File 'lib/udb_helpers/backend_helpers.rb', line 205 def anchor_for_udb_doc_ext(ext_name) "[#udb:doc:ext:#{ext_name.sanitize}]" end |
#anchor_for_udb_doc_ext_param(ext_name, param_name) ⇒ String
Returns An anchor for UDB parameter documentation.
212 213 214 215 |
# File 'lib/udb_helpers/backend_helpers.rb', line 212 def anchor_for_udb_doc_ext_param(ext_name, param_name) check_no_periods(param_name) "[#udb:doc:ext_param:#{ext_name.sanitize}:#{param_name}]" end |
#anchor_for_udb_doc_idl_func(name) ⇒ String
Returns An anchor for an IDL function documentation.
251 252 253 |
# File 'lib/udb_helpers/backend_helpers.rb', line 251 def anchor_for_udb_doc_idl_func(name) "[#udb:doc:func:#{name.sanitize}]" end |
#anchor_for_udb_doc_inst(name) ⇒ String
Returns An anchor for UDB instruction documentation.
219 220 221 |
# File 'lib/udb_helpers/backend_helpers.rb', line 219 def anchor_for_udb_doc_inst(name) "[#udb:doc:inst:#{name.sanitize}]" end |
#anchor_for_udb_doc_mmr(name) ⇒ String
Returns An anchor for UDB MMR documentation.
238 239 240 |
# File 'lib/udb_helpers/backend_helpers.rb', line 238 def anchor_for_udb_doc_mmr(name) "[#udb:doc:mmr:#{name.sanitize}]" end |
#anchor_for_udb_doc_mmr_field(mmr_name, field_name) ⇒ String
Returns An anchor for UDB MMR field documentation.
245 246 247 |
# File 'lib/udb_helpers/backend_helpers.rb', line 245 def anchor_for_udb_doc_mmr_field(mmr_name, field_name) "[#udb:doc:mmr_field:#{mmr_name.sanitize}:#{field_name.sanitize}]" end |
#anchor_inside_idl_inst_code(inst_name, id) ⇒ String
Returns An anchor inside IDL instruction code.
273 274 275 |
# File 'lib/udb_helpers/backend_helpers.rb', line 273 def anchor_inside_idl_inst_code(inst_name, id) "[#idl:code:inst:#{inst_name.sanitize}:#{id.sanitize}]" end |
#link_into_idl_inst_code(inst_name, id) ⇒ String
Returns A hyperlink into IDL instruction code.
194 195 196 |
# File 'lib/udb_helpers/backend_helpers.rb', line 194 def link_into_idl_inst_code(inst_name, id) "%%IDL_CODE_LINK%inst;#{inst_name.sanitize}.#{id.sanitize};#{inst_name}.#{id}%%" end |
#link_to_udb_doc_cov_pt(org, id) ⇒ String
Returns A hyperlink to a UDB certification normative rule (separate chapters for cov pts and test procs).
186 187 188 189 |
# File 'lib/udb_helpers/backend_helpers.rb', line 186 def link_to_udb_doc_cov_pt(org, id) raise ArgumentError, "Unknown org value of '#{org}' for ID '#{id}'" unless org == "sep" || org == "combo" || org == "appendix" "%%UDB_DOC_COV_PT_LINK%#{org};#{id.sanitize};#{id}%%" end |
#link_to_udb_doc_csr(csr_name) ⇒ String
Returns A hyperlink to UDB CSR documentation.
153 154 155 |
# File 'lib/udb_helpers/backend_helpers.rb', line 153 def link_to_udb_doc_csr(csr_name) "%%UDB_DOC_LINK%csr;#{csr_name.sanitize};#{csr_name}%%" end |
#link_to_udb_doc_csr_field(csr_name, field_name) ⇒ String
Returns A hyperlink to UDB CSR field documentation.
160 161 162 |
# File 'lib/udb_helpers/backend_helpers.rb', line 160 def link_to_udb_doc_csr_field(csr_name, field_name) "%%UDB_DOC_LINK%csr_field;#{csr_name}*#{field_name};#{csr_name}.#{field_name}%%" end |
#link_to_udb_doc_ext(ext_name) ⇒ String
Returns A hyperlink to UDB extension documentation.
132 133 134 |
# File 'lib/udb_helpers/backend_helpers.rb', line 132 def link_to_udb_doc_ext(ext_name) "%%UDB_DOC_LINK%ext;#{ext_name.sanitize};#{ext_name}%%" end |
#link_to_udb_doc_ext_param(ext_name, param_name, link_text) ⇒ String
Returns A hyperlink to UDB parameter documentation.
140 141 142 143 |
# File 'lib/udb_helpers/backend_helpers.rb', line 140 def link_to_udb_doc_ext_param(ext_name, param_name, link_text) check_no_periods(param_name) "%%UDB_DOC_LINK%ext_param;#{ext_name.sanitize}.#{param_name};#{link_text}%%" end |
#link_to_udb_doc_idl_func(func_name) ⇒ String
Returns A hyperlink to UDB IDL function documentation.
179 180 181 |
# File 'lib/udb_helpers/backend_helpers.rb', line 179 def link_to_udb_doc_idl_func(func_name) "%%UDB_DOC_LINK%func;#{func_name.sanitize};#{func_name}%%" end |
#link_to_udb_doc_inst(inst_name) ⇒ String
Returns A hyperlink to UDB instruction documentation.
147 148 149 |
# File 'lib/udb_helpers/backend_helpers.rb', line 147 def link_to_udb_doc_inst(inst_name) "%%UDB_DOC_LINK%inst;#{inst_name.sanitize};#{inst_name}%%" end |
#link_to_udb_doc_mmr(mmr_name) ⇒ String
Returns A hyperlink to UDB MMR documentation.
166 167 168 |
# File 'lib/udb_helpers/backend_helpers.rb', line 166 def link_to_udb_doc_mmr(mmr_name) "%%UDB_DOC_LINK%mmr;#{mmr_name.sanitize};#{mmr_name}%%" end |
#link_to_udb_doc_mmr_field(mmr_name, field_name) ⇒ String
Returns A hyperlink to UDB MMR field documentation.
173 174 175 |
# File 'lib/udb_helpers/backend_helpers.rb', line 173 def link_to_udb_doc_mmr_field(mmr_name, field_name) "%%UDB_DOC_LINK%mmr_field;#{mmr_name.sanitize}.#{field_name.sanitize};#{mmr_name}.#{field_name}%%" end |
#partial(template_pname, inputs = {}) ⇒ String
Include a partial ERB template into a full ERB template.
106 107 108 109 110 111 112 113 114 |
# File 'lib/udb_helpers/backend_helpers.rb', line 106 def partial(template_pname, inputs = {}) template_path = Pathname.new($root / "backends" / template_pname) raise ArgumentError, "Template '#{template_path} not found" unless template_path.exist? erb = ERB.new(template_path.read, trim_mode: "-") erb.filename = template_path.realpath.to_s erb.result(OpenStruct.new(inputs).instance_eval { binding }) end |