forked from aws/aws-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocevents.py
More file actions
106 lines (102 loc) · 4.76 KB
/
docevents.py
File metadata and controls
106 lines (102 loc) · 4.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
DOC_EVENTS = {
'doc-breadcrumbs': '.%s',
'doc-title': '.%s',
'doc-description': '.%s',
'doc-synopsis-start': '.%s',
'doc-synopsis-option': '.%s.%s',
'doc-synopsis-end': '.%s',
'doc-options-start': '.%s',
'doc-option': '.%s.%s',
'doc-option-example': '.%s.%s',
'doc-options-end': '.%s',
'doc-global-option': '.%s',
'doc-examples': '.%s',
'doc-output': '.%s',
'doc-subitems-start': '.%s',
'doc-subitem': '.%s.%s',
'doc-subitems-end': '.%s',
'doc-relateditems-start': '.%s',
'doc-relateditem': '.%s.%s',
'doc-relateditems-end': '.%s'
}
def generate_events(session, help_command):
# Now generate the documentation events
session.emit('doc-breadcrumbs.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-title.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-description.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-synopsis-start.%s' % help_command.event_class,
help_command=help_command)
if help_command.arg_table:
for arg_name in help_command.arg_table:
# An argument can set an '_UNDOCUMENTED' attribute
# to True to indicate a parameter that exists
# but shouldn't be documented. This can be used
# for backwards compatibility of deprecated arguments.
if getattr(help_command.arg_table[arg_name],
'_UNDOCUMENTED', False):
continue
session.emit(
'doc-synopsis-option.%s.%s' % (help_command.event_class,
arg_name),
arg_name=arg_name, help_command=help_command)
session.emit('doc-synopsis-end.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-options-start.%s' % help_command.event_class,
help_command=help_command)
if help_command.arg_table:
for arg_name in help_command.arg_table:
if getattr(help_command.arg_table[arg_name],
'_UNDOCUMENTED', False):
continue
session.emit('doc-option.%s.%s' % (help_command.event_class,
arg_name),
arg_name=arg_name, help_command=help_command)
session.emit('doc-option-example.%s.%s' %
(help_command.event_class, arg_name),
arg_name=arg_name, help_command=help_command)
session.emit('doc-options-end.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-global-option.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-subitems-start.%s' % help_command.event_class,
help_command=help_command)
if help_command.command_table:
for command_name in sorted(help_command.command_table.keys()):
if hasattr(help_command.command_table[command_name],
'_UNDOCUMENTED'):
continue
session.emit('doc-subitem.%s.%s'
% (help_command.event_class, command_name),
command_name=command_name,
help_command=help_command)
session.emit('doc-subitems-end.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-examples.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-output.%s' % help_command.event_class,
help_command=help_command)
session.emit('doc-relateditems-start.%s' % help_command.event_class,
help_command=help_command)
if help_command.related_items:
for related_item in sorted(help_command.related_items):
session.emit('doc-relateditem.%s.%s'
% (help_command.event_class, related_item),
help_command=help_command,
related_item=related_item)
session.emit('doc-relateditems-end.%s' % help_command.event_class,
help_command=help_command)