Class: Docbook::Elements::RefEntry

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Includes:
DocbookElement, Identifiable, SectionLike, Titled, TocContainer
Defined in:
lib/docbook/elements/refentry.rb

Instance Method Summary collapse

Methods included from Titled

#has_title?, #titled?

Methods included from SectionLike

#section_like?

Methods included from DocbookElement

#callout_marker?, #colsep, #content, #fileref, #formal?, #frame, #has_title?, #imagedata, #imageobject, #index_term?, #indexterm, #info, #list_of_category, #media_children, #number, #numberable?, #numbering_role, #rowsep, #section_like?, #stats_category, #text, #title, #titled?, #try_add_inline, #videoobject, #walk_children, #xml_id, #xref?

Instance Method Details

#element_idObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/docbook/elements/refentry.rb', line 21

def element_id
  id = xml_id
  return id.to_s if id && !id.to_s.empty?

  if refmeta&.fieldsynopsis&.any?
    vn = refmeta.fieldsynopsis.first.varname
    return "p_#{vn.content.join}" if vn&.content&.any?
  end

  "elem-#{object_id}"
end

#resolve_titleObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/docbook/elements/refentry.rb', line 33

def resolve_title
  if refmeta
    if refmeta.refentrytitle&.content&.any?
      return refmeta.refentrytitle.content.join
    end

    fs = refmeta.fieldsynopsis
    if fs && !fs.empty? && fs.first.varname&.content&.any?
      return fs.first.varname.content.join
    end
  end
  if refnamediv&.refname&.any?
    return refnamediv.refname.map { |n| n.content.join }.join(", ")
  end

  nil
end

#toc_childrenObject



12
13
14
15
16
17
18
19
# File 'lib/docbook/elements/refentry.rb', line 12

def toc_children
  [
    *Array(refsection),
    *Array(refsect1),
    *Array(refsect2),
    *Array(refsect3),
  ]
end