]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
a8f87751a0fa9d3bfcb73f917c66ad93eed55954
3 # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
8 from __future__
import print_function
9 from __future__
import absolute_import
12 from .message
import *
15 def __init__(self
, name
, tag
=''):
18 self
.mDescription
= ''
21 def AddDescription(self
, desc
):
22 self
.mDescription
= '%s%s' % (self
.mDescription
, desc
)
25 return '\n'.join(self
.mText
)
28 """This interface need to be override"""
30 class Section(BaseDoxygeItem
):
32 """This interface need to be override"""
33 if len(self
.mTag
) != 0:
34 self
.mText
.append(' \section %s %s' % (self
.mName
, self
.mTag
))
36 self
.mText
.append(' \section %s' % self
.mName
)
38 self
.mText
.append(self
.mDescription
)
41 class Page(BaseDoxygeItem
):
42 def __init__(self
, name
, tag
=None, isSort
=True):
43 BaseDoxygeItem
.__init
__(self
, name
, tag
)
45 self
.mIsMainPage
= False
49 def GetSubpageCount(self
):
50 return len(self
.mSubPages
)
52 def AddPage(self
, subpage
):
53 self
.mSubPages
.append(subpage
)
56 def AddPages(self
, pageArray
):
59 for page
in pageArray
:
62 def AddSection(self
, section
):
63 self
.mSections
.append(section
)
64 self
.mSections
.sort(key
=lambda x
: x
.mName
.lower())
68 self
.mText
.append('/** \mainpage %s' % self
.mName
)
71 self
.mText
.append('/** \page %s %s' % (self
.mTag
, self
.mName
))
73 if len(self
.mDescription
) != 0:
74 self
.mText
.append(self
.mDescription
)
75 endIndex
= len(self
.mText
)
77 self
.mSections
.sort(key
=lambda x
: x
.mName
.lower())
78 for sect
in self
.mSections
:
79 self
.mText
+= sect
.Generate()
81 endIndex
= len(self
.mText
)
83 if len(self
.mSubPages
) != 0:
84 self
.mText
.insert(endIndex
, "<p> \section content_index INDEX")
85 endIndex
= len(self
.mText
)
86 self
.mText
.insert(endIndex
, '<ul>')
89 self
.mSubPages
.sort(key
=lambda x
: x
.mName
.lower())
90 for page
in self
.mSubPages
:
91 self
.mText
.insert(endIndex
, '<li>\subpage %s \"%s\" </li>' % (page
.mTag
, page
.mName
))
93 self
.mText
+= page
.Generate()
94 self
.mText
.insert(endIndex
, '</ul>')
96 self
.mText
.insert(endIndex
, ' **/')
99 class DoxygenFile(Page
):
100 def __init__(self
, name
, file):
101 Page
.__init
__(self
, name
)
102 self
.mFilename
= file
103 self
.mIsMainPage
= True
105 def GetFilename(self
):
106 return self
.mFilename
.replace('/', '\\')
109 str = self
.Generate()
111 f
= open(self
.mFilename
, 'w')
112 f
.write('\n'.join(str))
115 ErrorMsg ('Fail to write file %s' % self
.mFilename
)
120 doxygenConfigTemplate
= """
121 DOXYFILE_ENCODING = UTF-8
122 PROJECT_NAME = %(ProjectName)s
123 PROJECT_NUMBER = %(ProjectVersion)s
124 OUTPUT_DIRECTORY = %(OutputDir)s
126 OUTPUT_LANGUAGE = English
127 BRIEF_MEMBER_DESC = YES
129 ABBREVIATE_BRIEF = "The $name class " \\
130 "The $name widget " \\
140 ALWAYS_DETAILED_SEC = NO
141 INLINE_INHERITED_MEMB = NO
142 FULL_PATH_NAMES = YES
143 STRIP_FROM_PATH = %(StripPath)s
144 STRIP_FROM_INC_PATH =
146 JAVADOC_AUTOBRIEF = NO
148 MULTILINE_CPP_IS_BRIEF = NO
151 SEPARATE_MEMBER_PAGES = NO
154 OPTIMIZE_OUTPUT_FOR_C = YES
155 OPTIMIZE_OUTPUT_JAVA = NO
156 BUILTIN_STL_SUPPORT = NO
159 DISTRIBUTE_GROUP_DOC = YES
161 TYPEDEF_HIDES_STRUCT = NO
166 EXTRACT_LOCAL_CLASSES = NO
167 EXTRACT_LOCAL_METHODS = NO
168 EXTRACT_ANON_NSPACES = NO
169 HIDE_UNDOC_MEMBERS = NO
170 HIDE_UNDOC_CLASSES = NO
171 HIDE_FRIEND_COMPOUNDS = NO
172 HIDE_IN_BODY_DOCS = NO
174 CASE_SENSE_NAMES = NO
175 HIDE_SCOPE_NAMES = NO
176 SHOW_INCLUDE_FILES = NO
178 SORT_MEMBER_DOCS = YES
180 SORT_BY_SCOPE_NAME = YES
181 GENERATE_TODOLIST = YES
182 GENERATE_TESTLIST = YES
183 GENERATE_BUGLIST = YES
184 GENERATE_DEPRECATEDLIST= YES
186 MAX_INITIALIZER_LINES = 30
188 SHOW_DIRECTORIES = NO
189 FILE_VERSION_FILTER =
193 WARN_IF_UNDOCUMENTED = YES
194 WARN_IF_DOC_ERROR = YES
195 WARN_NO_PARAMDOC = YES
196 WARN_FORMAT = "$file:$line: $text "
197 WARN_LOGFILE = %(WarningFile)s
200 INPUT_ENCODING = UTF-8
201 FILE_PATTERNS = %(Pattern)s
204 EXCLUDE_SYMLINKS = NO
205 EXCLUDE_PATTERNS = .svn
207 EXAMPLE_PATH = %(ExamplePath)s
209 EXAMPLE_RECURSIVE = NO
213 FILTER_SOURCE_FILES = NO
217 STRIP_CODE_COMMENTS = YES
218 REFERENCED_BY_RELATION = YES
219 REFERENCES_RELATION = YES
220 REFERENCES_LINK_SOURCE = NO
222 VERBATIM_HEADERS = NO
224 ALPHABETICAL_INDEX = NO
225 COLS_IN_ALPHA_INDEX = 5
230 HTML_FILE_EXTENSION = .html
234 HTML_ALIGN_MEMBERS = YES
235 GENERATE_HTMLHELP = %(WhetherGenerateHtmlHelp)s
236 HTML_DYNAMIC_SECTIONS = NO
243 ENUM_VALUES_PER_LINE = 4
244 GENERATE_TREEVIEW = %(WhetherGenerateTreeView)s
249 LATEX_CMD_NAME = latex
250 MAKEINDEX_CMD_NAME = makeindex
258 LATEX_HIDE_INDICES = NO
264 RTF_STYLESHEET_FILE =
265 RTF_EXTENSIONS_FILE =
276 XML_PROGRAMLISTING = YES
278 GENERATE_AUTOGEN_DEF = NO
280 GENERATE_PERLMOD = NO
283 PERLMOD_MAKEVAR_PREFIX =
285 ENABLE_PREPROCESSING = YES
286 MACRO_EXPANSION = YES
287 EXPAND_ONLY_PREDEF = YES
288 SEARCH_INCLUDES = YES
289 INCLUDE_PATH = %(IncludePath)s
290 INCLUDE_FILE_PATTERNS = *.h
291 PREDEFINED = %(PreDefined)s
293 SKIP_FUNCTION_MACROS = NO
298 EXTERNAL_GROUPS = YES
299 PERL_PATH = /usr/bin/perl
303 HIDE_UNDOC_RELATIONS = YES
306 COLLABORATION_GRAPH = YES
309 TEMPLATE_RELATIONS = NO
311 INCLUDED_BY_GRAPH = YES
314 GRAPHICAL_HIERARCHY = YES
315 DIRECTORY_GRAPH = YES
316 DOT_IMAGE_FORMAT = png
319 DOT_GRAPH_MAX_NODES = 50
320 MAX_DOT_GRAPH_DEPTH = 1000
321 DOT_TRANSPARENT = YES
322 DOT_MULTI_TARGETS = NO
323 GENERATE_LEGEND = YES
329 class DoxygenConfigFile
:
331 self
.mProjectName
= ''
334 self
.mIncludeList
= []
336 self
.mExamplePath
= ''
337 self
.mPattern
= ['*.c', '*.h',
338 '*.asm', '*.s', '.nasm', '*.html', '*.dox']
340 self
.mWarningFile
= ''
341 self
.mPreDefined
= []
342 self
.mProjectVersion
= 0.1
344 def SetChmMode(self
):
347 def SetHtmlMode(self
):
350 def SetProjectName(self
, str):
351 self
.mProjectName
= str
353 def SetProjectVersion(self
, str):
354 self
.mProjectVersion
= str
356 def SetOutputDir(self
, str):
357 self
.mOutputDir
= str
359 def SetStripPath(self
, str):
360 self
.mStripPath
= str
362 def SetExamplePath(self
, str):
363 self
.mExamplePath
= str
365 def SetWarningFilePath(self
, str):
366 self
.mWarningFile
= str.replace('\\', '/')
368 def FileExists(self
, path
):
374 for p
in self
.mFileList
:
375 if path
.lower() == p
.lower():
380 def AddFile(self
, path
):
386 path
= path
.replace('\\', '/')
387 if not self
.FileExists(path
):
388 self
.mFileList
.append(path
)
390 def AddIncludePath(self
, path
):
391 path
= path
.replace('\\', '/')
392 if path
not in self
.mIncludeList
:
393 self
.mIncludeList
.append(path
)
395 def AddPattern(self
, pattern
):
396 self
.mPattern
.append(pattern
)
398 def AddPreDefined(self
, macro
):
399 self
.mPreDefined
.append(macro
)
401 def Generate(self
, path
):
402 files
= ' \\\n'.join(self
.mFileList
)
403 includes
= ' \\\n'.join(self
.mIncludeList
)
404 patterns
= ' \\\n'.join(self
.mPattern
)
405 if self
.mMode
.lower() == 'html':
412 text
= doxygenConfigTemplate
% {'ProjectName':self
.mProjectName
,
413 'OutputDir':self
.mOutputDir
,
414 'StripPath':self
.mStripPath
,
415 'ExamplePath':self
.mExamplePath
,
418 'WhetherGenerateHtmlHelp':sHtmlHelp
,
419 'WhetherGenerateTreeView':sTreeView
,
420 'IncludePath':includes
,
421 'WarningFile':self
.mWarningFile
,
422 'PreDefined':' '.join(self
.mPreDefined
),
423 'ProjectVersion':self
.mProjectVersion
}
429 ErrorMsg ('Fail to generate doxygen config file %s' % path
)
434 ########################################################################
436 ########################################################################
437 if __name__
== '__main__':
438 df
= DoxygenFile('Platform Document', 'm:\tree')
439 df
.AddPage(Page('Module', 'module'))
440 p
= df
.AddPage(Page('Library', 'library'))
441 p
.AddDescription(desc
)
442 p
.AddPage(Page('PCD', 'pcds'))