Skip to content

Commit 923e36b

Browse files
author
Max Schaefer
committed
C++/Java/JavaScript/Python: Make qldoc consistent.
1 parent a2fe678 commit 923e36b

File tree

4 files changed

+192
-75
lines changed
  • cpp/ql/src/semmle/code/cpp
  • javascript/ql/src/semmle/javascript
  • java/ql/src/semmle/code/xml
  • python/ql/src/semmle/python/xml

4 files changed

+192
-75
lines changed

cpp/ql/src/semmle/code/cpp/XML.qll

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ abstract class XMLLocatable extends @xmllocatable {
1010
Location getLocation() { xmllocations(this, result) }
1111

1212
/**
13-
* Holds if this element has the specified location information,
14-
* including file path, start line, start column, end line and end column.
13+
* Holds if this element is at the specified location.
14+
* The location spans column `startcolumn` of line `startline` to
15+
* column `endcolumn` of line `endline` in file `filepath`.
16+
* For more information, see
17+
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
1518
*/
1619
predicate hasLocationInfo(
1720
string filepath, int startline, int startcolumn, int endline, int endcolumn
@@ -22,7 +25,7 @@ abstract class XMLLocatable extends @xmllocatable {
2225
)
2326
}
2427

25-
/** Gets a printable representation of this element. */
28+
/** Gets a textual representation of this element. */
2629
abstract string toString();
2730
}
2831

@@ -135,7 +138,17 @@ class XMLFile extends XMLParent, File {
135138
XMLDTD getADTD() { xmlDTDs(result, _, _, _, this) }
136139
}
137140

138-
/** A "Document Type Definition" of an XML file. */
141+
/**
142+
* An XML document type definition (DTD).
143+
*
144+
* Example:
145+
*
146+
* ```
147+
* <!ELEMENT person (firstName, lastName?)>
148+
* <!ELEMENT firstName (#PCDATA)>
149+
* <!ELEMENT lastName (#PCDATA)>
150+
* ```
151+
*/
139152
class XMLDTD extends @xmldtd {
140153
/** Gets the name of the root element of this DTD. */
141154
string getRoot() { xmlDTDs(this, result, _, _, _) }
@@ -162,7 +175,17 @@ class XMLDTD extends @xmldtd {
162175
}
163176
}
164177

165-
/** An XML tag in an XML file. */
178+
/**
179+
* An XML element in an XML file.
180+
*
181+
* Example:
182+
*
183+
* ```
184+
* <manifest xmlns:android="http://schemas.android.com/apk/res/android"
185+
* package="com.example.exampleapp" android:versionCode="1">
186+
* </manifest>
187+
* ```
188+
*/
166189
class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
167190
/** Holds if this XML element has the given `name`. */
168191
predicate hasName(string name) { name = getName() }
@@ -207,7 +230,16 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
207230
override string toString() { result = XMLParent.super.toString() }
208231
}
209232

210-
/** An attribute that occurs inside an XML element. */
233+
/**
234+
* An attribute that occurs inside an XML element.
235+
*
236+
* Examples:
237+
*
238+
* ```
239+
* package="com.example.exampleapp"
240+
* android:versionCode="1"
241+
* ```
242+
*/
211243
class XMLAttribute extends @xmlattribute, XMLLocatable {
212244
/** Gets the name of this attribute. */
213245
string getName() { xmlAttrs(this, _, result, _, _, _) }
@@ -228,7 +260,15 @@ class XMLAttribute extends @xmlattribute, XMLLocatable {
228260
override string toString() { result = this.getName() + "=" + this.getValue() }
229261
}
230262

231-
/** A namespace used in an XML file */
263+
/**
264+
* A namespace used in an XML file.
265+
*
266+
* Example:
267+
*
268+
* ```
269+
* xmlns:android="http://schemas.android.com/apk/res/android"
270+
* ```
271+
*/
232272
class XMLNamespace extends @xmlnamespace {
233273
/** Gets the prefix of this namespace. */
234274
string getPrefix() { xmlNs(this, result, _, _) }
@@ -247,7 +287,15 @@ class XMLNamespace extends @xmlnamespace {
247287
}
248288
}
249289

250-
/** A comment of the form `<!-- ... -->` is an XML comment. */
290+
/**
291+
* A comment in an XML file.
292+
*
293+
* Example:
294+
*
295+
* ```
296+
* <!-- This is a comment. -->
297+
* ```
298+
*/
251299
class XMLComment extends @xmlcomment, XMLLocatable {
252300
/** Gets the text content of this XML comment. */
253301
string getText() { xmlComments(this, result, _, _) }
@@ -262,6 +310,12 @@ class XMLComment extends @xmlcomment, XMLLocatable {
262310
/**
263311
* A sequence of characters that occurs between opening and
264312
* closing tags of an XML element, excluding other elements.
313+
*
314+
* Example:
315+
*
316+
* ```
317+
* <content>This is a sequence of characters.</content>
318+
* ```
265319
*/
266320
class XMLCharacters extends @xmlcharacters, XMLLocatable {
267321
/** Gets the content of this character sequence. */

java/ql/src/semmle/code/xml/XML.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ class XMLParent extends @xmlparent {
8888
)
8989
}
9090

91-
/** Append all the character sequences of this XML parent from left to right, separated by a space. */
91+
/**
92+
* Gets the result of appending all the character sequences of this XML parent from
93+
* left to right, separated by a space.
94+
*/
9295
string allCharactersString() {
9396
result = concat(string chars, int pos |
9497
xmlChars(_, chars, this, pos, _, _)

javascript/ql/src/semmle/javascript/XML.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ class XMLParent extends @xmlparent {
8888
)
8989
}
9090

91-
/** Append all the character sequences of this XML parent from left to right, separated by a space. */
91+
/**
92+
* Gets the result of appending all the character sequences of this XML parent from
93+
* left to right, separated by a space.
94+
*/
9295
string allCharactersString() {
9396
result = concat(string chars, int pos |
9497
xmlChars(_, chars, this, pos, _, _)

0 commit comments

Comments
 (0)