Skip to content

Commit 5271184

Browse files
committed
Improve high-level api docs
1 parent 912f2bf commit 5271184

File tree

4 files changed

+92
-3
lines changed

4 files changed

+92
-3
lines changed

shared/src/main/scala/scala/xml/Elem.scala

+9-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ object Elem {
6666
}
6767

6868
/**
69-
* The case class `Elem` extends the `Node` class,
70-
* providing an immutable data object representing an XML element.
69+
* An immutable data object representing an XML element.
70+
*
71+
* Child elements can be other [[Elem]]s or any one of the other [[Node]] types.
72+
*
73+
* XML attributes are implemented with the [[scala.xml.MetaData]] base
74+
* class.
75+
*
76+
* Optional XML namespace scope is represented by
77+
* [[scala.xml.NamespaceBinding]].
7178
*
7279
* @param prefix namespace prefix (may be null, but not the empty string)
7380
* @param label the element name

shared/src/main/scala/scala/xml/Node.scala

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ object Node {
2727
}
2828

2929
/**
30-
* An abstract class representing XML with nodes of a labelled tree.
30+
* An abstract class representing XML with nodes of a labeled tree.
3131
* This class contains an implementation of a subset of XPath for navigation.
3232
*
33+
* - [[scala.xml.Comment]] — XML comment
34+
* - [[scala.xml.Elem]] — XML element
35+
* - [[scala.xml.EntityRef]] — XML entity
36+
* - [[scala.xml.PCData]] — Character data section (CDATA)
37+
* - [[scala.xml.ProcInstr]] — Processing instruction (PI)
38+
* - [[scala.xml.Text]] — Stand-alone parsed character data
39+
*
3340
* @author Burak Emir and others
3441
* @version 1.1
3542
*/

shared/src/main/scala/scala/xml/dtd/Decl.scala

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ package dtd
1212

1313
import Utility.sbToString
1414

15+
/**
16+
* XML declarations
17+
*
18+
* - [[scala.xml.dtd.AttListDecl]] — Attribute list declaration (ATTLIST)
19+
* - [[scala.xml.dtd.AttrDecl]] — Attribute declaration
20+
* - [[scala.xml.dtd.ElemDecl]] — Element declaration (ELEMENT)
21+
* - [[scala.xml.dtd.ParameterEntityDecl]] — Parameter entity list (ENTITY %)
22+
* - [[scala.xml.dtd.ParsedEntityDecl]] — Parsed general entity list (ENTITY)
23+
* - [[scala.xml.dtd.PEReference]] — Parsed entity reference
24+
* - [[scala.xml.dtd.UnparsedEntityDecl]] — Unparsed entity list (ENTITY NDATA)
25+
*/
1526
sealed abstract class Decl
1627

1728
sealed abstract class MarkupDecl extends Decl {

shared/src/main/scala/scala/xml/package.scala

+64
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,70 @@
88

99
package scala
1010

11+
/**
12+
* This library provides support for the XML literal syntax in Scala programs.
13+
* {{{
14+
* val planets: scala.xml.Elem = <planets>
15+
* <planet id="earth">
16+
* <title>Earth</title>
17+
* <mass unit="kg">5.9742e24</mass>
18+
* <radius unit="m">6378.14e3</radius>
19+
* </planet>
20+
* <planet id="mars">
21+
* <title>Mars</title>
22+
* <mass unit="kg">0.64191e24</mass>
23+
* <radius unit="m">3397.0e3</radius>
24+
* </planet>
25+
* </planets>
26+
* }}}
27+
*
28+
* Additionally, you can mix Scala expressions in your XML elements by
29+
* using the curly brace notation:
30+
*
31+
* {{{
32+
* val sunMass = 1.99e30
33+
* val sunRadius = 6.96e8
34+
* val star = <star>
35+
* <title>Sun</title>
36+
* <mass unit="kg">{ sunMass }</mass>
37+
* <radius unit="m">{ sunRadius }</radius>
38+
* <surface unit="m²">{ 4 * Math.PI * Math.pow(sunRadius, 2) }</surface>
39+
* <volume unit="m³">{ 4/3 * Math.PI * Math.pow(sunRadius, 3) }</volume>
40+
* </star>
41+
* }}}
42+
*
43+
* An XML element, for example `<star/>` and `<planet/>`, is
44+
* represented in this library as a case class, [[scala.xml.Elem]].
45+
*
46+
* The sub-elements of XML values share a common base class,
47+
* [[scala.xml.Node]].
48+
*
49+
* However, the non-element declarations found in XML files share a
50+
* different common base class, [[scala.xml.dtd.Decl]]. Additionally,
51+
* document type declarations are represented by a different trait,
52+
* [[scala.xml.dtd.DTD]].
53+
*
54+
* For reading and writing XML data to and from files, see
55+
* [[scala.xml.XML]]. The default parser of XML data is the
56+
* [[http://xerces.apache.org/ Xerces]] parser and is provided in Java
57+
* by [[javax.xml.parsers.SAXParser]].
58+
*
59+
* A less greedy XML reader can return data as a sequential collection
60+
* of events, see [[scala.xml.pull.XMLEventReader]].
61+
*
62+
* For more control of the input, use the parser written in Scala that
63+
* is provided, [[scala.xml.parsing.ConstructingParser]].
64+
*
65+
* For working with XHTML input, use [[scala.xml.parsing.XhtmlParser]].
66+
*
67+
* For more control of the output, use the [[scala.xml.PrettyPrinter]].
68+
*
69+
* Utility methods for working with XML data are provided in
70+
* [[scala.xml.Utility]].
71+
*
72+
* XML values in Scala are immutable, but you can traverse and
73+
* transform XML data with a [[scala.xml.transform.RuleTransformer]].
74+
*/
1175
package object xml {
1276
val XercesClassName = "org.apache.xerces.parsers.SAXParser"
1377

0 commit comments

Comments
 (0)