1 # $Id: id.rb,v 1.7 2011/12/02 01:46:54 machan Exp $
2
3 require 'tmdoc/tmstd'
4 require 'tmdoc/tmstd/docbook'
5 require 'tmdoc/constant'
6 require 'tmdoc/model/document'
7 require 'tmdoc/transformer/core-into-module/constant'
8
9
10 module TmDoc
11
12 module Transformer::DocumentIntoDocBook
13
14 module Id
15 SEP = '.'
16
17 PREFIX = 'tmdoc'
18 DIV_PREFIX = PREFIX + SEP + 'div'
19 SRC_PREFIX = PREFIX + SEP + 'src'
20 DEF_PREFIX = PREFIX + SEP + 'def'
21
22 HOME = PREFIX + SEP + 'home'
23 INDEX = PREFIX + SEP + 'index'
24
25 DIV_OVERVIEW = DIV_PREFIX + SEP + 'overview'
26 DIV_UNKNOWN_M_AND_C = DIV_PREFIX + SEP + 'unknown-modules'
27 DIV_BUILTIN_M_AND_C = DIV_PREFIX + SEP + 'builtin-modules'
28 DIV_USER_M_AND_C = DIV_PREFIX + SEP + 'user-modules'
29 DIV_SOURCES = DIV_PREFIX + SEP + 'sources'
30
31 DIV_OV_M_STRUCTURE = DIV_PREFIX + SEP + 'ov-m-structure'
32 DIV_OV_C_HIERARCHY = DIV_PREFIX + SEP + 'ov-c-hierarchy'
33 DIV_OV_S_STRUCTURE = DIV_PREFIX + SEP + 'ov-s-structure'
34
35 DIV_NAME_OF_M_STRUCTURE = 'm-structure'
36 DIV_NAME_OF_C_HIERARCHY = 'c-hierarchy'
37 DIV_NAME_OF_S_STRUCTURE = 's-structure'
38 DIV_NAME_OF_CODE = 'code'
39
40 NODE_FOCUS = 'focus'
41
42 PROP_PREFIX = '+'
43
44
45 module_function
46
47 def transform_line(file_name, line_num)
48 ASSERT.kind_of file_name, String
49
50 id_line = transform_file(file_name) + SEP + line_num.to_s
51
52 ASSERT.kind_of id_line, String
53 end
54
55
56 def transform_file(name)
57 ASSERT.kind_of name, String
58
59 id_file = SRC_PREFIX + SEP + name.gsub('/', SEP)
60
61 ASSERT.kind_of id_file, String
62 end
63
64
65 def transform_module(above_path, name)
66 ASSERT.kind_of above_path, MD::Path
67 ASSERT.opt_kind_of name, String
68
69 id_module = DEF_PREFIX + SEP + (
70 if above_path.empty?
71 if name
72 name
73 else
74 CoreIntoModule::TOPLEVEL_MODULE_NAME
75 end
76 else
77 (above_path << name).join SEP
78 end
79 )
80
81 ASSERT.kind_of id_module, String
82 end
83
84
85 def transform_module_section(module_id, section_name)
86 ASSERT.kind_of module_id, String
87 ASSERT.kind_of section_name, String
88
89 id_module_sect = module_id + SEP + section_name
90
91 ASSERT.kind_of id_module_sect, String
92 end
93
94
95 def transform_focus(section_id)
96 ASSERT.kind_of section_id, String
97
98 id_focus = section_id + SEP + NODE_FOCUS
99
100 ASSERT.kind_of id_focus, String
101 end
102
103
104 def transform_property(module_id, name, uniq_num = 0)
105 ASSERT.kind_of module_id, String
106 ASSERT.kind_of name, String
107 ASSERT.kind_of uniq_num, Integer
108
109 id_property =
110 module_id + SEP +
111 PROP_PREFIX + name + (
112 if uniq_num == 0
113 ''
114 else
115 format "-%d", uniq_num
116 end
117 )
118
119 ASSERT.kind_of id_property, String
120 end
121 end
122
123 end # TmDoc::Transformer::DocumentIntoDocBook
124
125 end # TmDoc