Skip to content

Commit 12ecfa8

Browse files
Added deprecated API indication in the API doc (#6545)
* Added deprecated command indication as (D) in the API doc * Fixed line allignment
1 parent 7a1401a commit 12ecfa8

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

server/src/main/java/com/cloud/api/doc/ApiXmlDocWriter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,11 @@ private static void writeCommand(ObjectOutputStream out, String command) throws
214214
}
215215

216216
boolean isAsync = ReflectUtil.isCmdClassAsync(clas, new Class<?>[] {BaseAsyncCmd.class, BaseAsyncCreateCmd.class});
217-
218217
apiCommand.setAsync(isAsync);
219218

219+
boolean isDeprecated = clas.getAnnotation(Deprecated.class) != null;
220+
apiCommand.setDeprecated(isDeprecated);
221+
220222
Set<Field> fields = ReflectUtil.getAllFieldsForClass(clas, new Class<?>[] {BaseCmd.class, BaseAsyncCmd.class, BaseAsyncCreateCmd.class});
221223

222224
request = setRequestFields(fields);

server/src/main/java/com/cloud/api/doc/Command.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class Command implements Serializable{
3232
private String sinceVersion = null;
3333
private ArrayList<Argument> request;
3434
private ArrayList<Argument> response;
35+
private boolean isDeprecated;
3536

3637
public Command(String name, String description) {
3738
this.name = name;
@@ -114,4 +115,12 @@ public String getUsage() {
114115
public void setUsage(String usage) {
115116
this.usage = usage;
116117
}
118+
119+
public boolean isDeprecated() {
120+
return isDeprecated;
121+
}
122+
123+
public void setDeprecated(boolean deprecated) {
124+
isDeprecated = deprecated;
125+
}
117126
}

tools/apidoc/gen_toc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,15 @@ def choose_category(fn):
234234
dom = minidom.parse(data)
235235
name = dom.getElementsByTagName('name')[0].firstChild.data
236236
isAsync = dom.getElementsByTagName('isAsync')[0].firstChild.data
237+
isDeprecated = dom.getElementsByTagName('isDeprecated')[0].firstChild.data
237238
category = choose_category(fn)
238239
if category not in categories:
239240
categories[category] = []
240241
categories[category].append({
241242
'name': name,
242243
'dirname': dirname_to_dirname[dirname],
243244
'async': isAsync == 'true',
245+
'deprecated': isDeprecated == 'true',
244246
'user': dirname_to_user[dirname],
245247
})
246248
except ExpatError as e:
@@ -252,9 +254,10 @@ def choose_category(fn):
252254
def xml_for(command):
253255
name = command['name']
254256
isAsync = command['async'] and ' (A)' or ''
257+
isDeprecated = command['deprecated'] and ' (D)' or ''
255258
dirname = command['dirname']
256259
return '''<xsl:if test="name=\'%(name)s\'">
257-
<li><a href="%(dirname)s/%(name)s.html"><xsl:value-of select="name"/>%(isAsync)s</a></li>
260+
<li><a href="%(dirname)s/%(name)s.html"><xsl:value-of select="name"/>%(isAsync)s %(isDeprecated)s</a></li>
258261
</xsl:if>
259262
''' % locals()
260263

tools/apidoc/generatetoc_header.xsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ version="1.0">
6666
<span>Commands available through the developer API URL and the integration API URL.</span>
6767
<div class="api_legends">
6868
<p><span class="api_legends_async">(A)</span> implies that the command is asynchronous.</p>
69+
<p><span class="api_legends_async">(D)</span> implies that the command is deprecated.</p>
6970
<p>(*) implies element has a child.</p>
7071
</div>

0 commit comments

Comments
 (0)