Class: DocbookFiles::Docbook

Inherits:
Object
  • Object
show all
Defined in:
lib/docbook_files/docbook.rb

Overview

Analyzes a DocBook 5 file for included and referenced files.

Constant Summary collapse

DOCBOOK_NS =

The DocBook 5 namespace URL

'http://docbook.org/ns/docbook'
XINCLUDE_NS =

The XInclude namespace URL

'http://www.w3.org/2001/XInclude'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fname) ⇒ Docbook

Initialize vars and quiet the libxml error handler. See libxml.rubyforge.org/rdoc/classes/LibXML/XML/Error.html



21
22
23
24
25
# File 'lib/docbook_files/docbook.rb', line 21

def initialize(fname)
  @main_name = fname
  @fd_tree = nil
  XML::Error.set_handler(&XML::Error::QUIET_HANDLER)
end

Instance Attribute Details

#fd_treeObject (readonly)

The FileData tree representing the file hierarchy



17
18
19
# File 'lib/docbook_files/docbook.rb', line 17

def fd_tree
  @fd_tree
end

Instance Method Details

#listObject

Return the FileData tree representing the include hierarchy.



30
31
32
33
# File 'lib/docbook_files/docbook.rb', line 30

def list
  @fd_tree ||= analyze_file(@main_name,File.dirname(@main_name))
  @fd_tree
end

#list_as_table(props) ⇒ Object

Return a flat array of FileDatas, a table with level indicator. The format is easier for tabular output.



44
45
46
47
# File 'lib/docbook_files/docbook.rb', line 44

def list_as_table(props)
  tree = self.list()
  tree.traverse_as_table(props)
end

#list_namesObject

Return all file names in a tree



36
37
38
39
# File 'lib/docbook_files/docbook.rb', line 36

def list_names
  fl = self.list()
  fl.names
end