Skip to content

Commit ffd2ef7

Browse files
authored
Document Dom\TokenList (#4306)
1 parent f0d1192 commit ffd2ef7

File tree

12 files changed

+791
-6
lines changed

12 files changed

+791
-6
lines changed

language-snippets.ent

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,27 @@ it is inserted with (e.g.) <function xmlns="http://docbook.org/ns/docbook">DOMNo
16791679
resulting HTML.
16801680
</simpara>
16811681
</warning>'>
1682+
<!ENTITY dom.tokenlist.errors '<itemizedlist xmlns="http://docbook.org/ns/docbook">
1683+
<listitem>
1684+
<simpara>
1685+
Throws a <exceptionname>ValueError</exceptionname> if
1686+
a token contains any null bytes.
1687+
</simpara>
1688+
</listitem>
1689+
<listitem>
1690+
<simpara>
1691+
Throws a <exceptionname>Dom\DOMException</exceptionname> with code
1692+
<constant>Dom\SYNTAX_ERR</constant> if a token is the empty string.
1693+
</simpara>
1694+
</listitem>
1695+
<listitem>
1696+
<simpara>
1697+
Throws a <exceptionname>Dom\DOMException</exceptionname> with code
1698+
<constant>Dom\INVALID_CHARACTER_ERR</constant> if a token contains any
1699+
ASCII whitespace.
1700+
</simpara>
1701+
</listitem>
1702+
</itemizedlist>'>
16821703

16831704

16841705

reference/dom/dom/dom-tokenlist.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@
4545
</fieldsynopsis>
4646

4747
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
48-
<classsynopsisinfo role="comment">Not documented yet</classsynopsisinfo>
49-
<!--<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dom-tokenlist')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='Dom\\TokenList'])">
50-
<xi:fallback/>
51-
</xi:include>
5248
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dom-tokenlist')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='Dom\\TokenList'])">
5349
<xi:fallback/>
54-
</xi:include>-->
50+
</xi:include>
5551
</classsynopsis>
5652
</section>
5753

@@ -76,10 +72,15 @@
7672
<section role="notes">
7773
&reftitle.notes;
7874
&dom.note.modern.utf8;
75+
<note>
76+
<simpara>
77+
Tokens in the list can be accessed by array syntax.
78+
</simpara>
79+
</note>
7980
</section>
8081

8182
</partintro>
8283

83-
<!-- &reference.dom.dom.entities.tokenlist; -->
84+
&reference.dom.dom.entities.tokenlist;
8485

8586
</reference>

reference/dom/dom/tokenlist/add.xml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<refentry xml:id="dom-tokenlist.add" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
<refnamediv>
4+
<refname>Dom\TokenList::add</refname>
5+
<refpurpose>Adds the given tokens to the list</refpurpose>
6+
</refnamediv>
7+
8+
<refsect1 role="description">
9+
&reftitle.description;
10+
<methodsynopsis role="Dom\\TokenList">
11+
<modifier>public</modifier> <type>void</type><methodname>Dom\TokenList::add</methodname>
12+
<methodparam rep="repeat"><type>string</type><parameter>tokens</parameter></methodparam>
13+
</methodsynopsis>
14+
<simpara>
15+
Adds the given <parameter>tokens</parameter> to the list, but not any that
16+
were already present.
17+
</simpara>
18+
</refsect1>
19+
20+
<refsect1 role="parameters">
21+
&reftitle.parameters;
22+
<variablelist>
23+
<varlistentry>
24+
<term><parameter>tokens</parameter></term>
25+
<listitem>
26+
<simpara>
27+
The tokens to add.
28+
</simpara>
29+
</listitem>
30+
</varlistentry>
31+
</variablelist>
32+
</refsect1>
33+
34+
<refsect1 role="returnvalues">
35+
&reftitle.returnvalues;
36+
<simpara>
37+
&return.void;
38+
</simpara>
39+
</refsect1>
40+
41+
<refsect1 role="errors">
42+
&reftitle.errors;
43+
&dom.tokenlist.errors;
44+
</refsect1>
45+
46+
<refsect1 role="examples">
47+
&reftitle.examples;
48+
<example xml:id="dom-tokenlist.add.example.basic">
49+
<title><methodname>Dom\TokenList::add</methodname> example</title>
50+
<simpara>
51+
Adds two classes to a newly created paragraph element.
52+
</simpara>
53+
<programlisting role="php">
54+
<![CDATA[
55+
<?php
56+
$dom = Dom\HTMLDocument::createEmpty();
57+
$p = $dom->createElement('p');
58+
59+
$classList = $p->classList;
60+
$classList->add('font-bold', 'important');
61+
62+
echo $dom->saveHtml($p);
63+
?>
64+
]]>
65+
</programlisting>
66+
&example.outputs;
67+
<screen>
68+
<![CDATA[
69+
<p class="font-bold important"></p>
70+
]]>
71+
</screen>
72+
</example>
73+
</refsect1>
74+
</refentry>
75+
<!-- Keep this comment at the end of the file
76+
Local variables:
77+
mode: sgml
78+
sgml-omittag:t
79+
sgml-shorttag:t
80+
sgml-minimize-attributes:nil
81+
sgml-always-quote-attributes:t
82+
sgml-indent-step:1
83+
sgml-indent-data:t
84+
indent-tabs-mode:nil
85+
sgml-parent-document:nil
86+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
87+
sgml-exposed-tags:nil
88+
sgml-local-catalogs:nil
89+
sgml-local-ecat-files:nil
90+
End:
91+
vim600: syn=xml fen fdm=syntax fdl=2 si
92+
vim: et tw=78 syn=sgml
93+
vi: ts=1 sw=1
94+
-->
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<refentry xml:id="dom-tokenlist.contains" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
<refnamediv>
4+
<refname>Dom\TokenList::contains</refname>
5+
<refpurpose>Returns whether the list contains a given token</refpurpose>
6+
</refnamediv>
7+
8+
<refsect1 role="description">
9+
&reftitle.description;
10+
<methodsynopsis role="Dom\\TokenList">
11+
<modifier>public</modifier> <type>bool</type><methodname>Dom\TokenList::contains</methodname>
12+
<methodparam><type>string</type><parameter>token</parameter></methodparam>
13+
</methodsynopsis>
14+
<simpara>
15+
Returns whether the list contains <parameter>token</parameter>.
16+
</simpara>
17+
</refsect1>
18+
19+
<refsect1 role="parameters">
20+
&reftitle.parameters;
21+
<variablelist>
22+
<varlistentry>
23+
<term><parameter>token</parameter></term>
24+
<listitem>
25+
<simpara>
26+
The token.
27+
</simpara>
28+
</listitem>
29+
</varlistentry>
30+
</variablelist>
31+
</refsect1>
32+
33+
<refsect1 role="returnvalues">
34+
&reftitle.returnvalues;
35+
<simpara>
36+
Returns &true; if the list contains <parameter>token</parameter>,
37+
&false; otherwise.
38+
</simpara>
39+
</refsect1>
40+
41+
<refsect1 role="examples">
42+
&reftitle.examples;
43+
<example xml:id="dom-tokenlist.contains.example.basic">
44+
<title><methodname>Dom\TokenList::contains</methodname> example</title>
45+
<simpara>
46+
Checks whether two classes are present on the paragraph.
47+
</simpara>
48+
<programlisting role="php">
49+
<![CDATA[
50+
<?php
51+
$dom = Dom\HTMLDocument::createFromString('<p class="font-bold important"></p>', LIBXML_NOERROR);
52+
$p = $dom->body->firstChild;
53+
54+
$classList = $p->classList;
55+
var_dump(
56+
$classList->contains('important'),
57+
$classList->contains('font-small'),
58+
);
59+
?>
60+
]]>
61+
</programlisting>
62+
&example.outputs;
63+
<screen>
64+
<![CDATA[
65+
bool(true)
66+
bool(false)
67+
]]>
68+
</screen>
69+
</example>
70+
</refsect1>
71+
</refentry>
72+
<!-- Keep this comment at the end of the file
73+
Local variables:
74+
mode: sgml
75+
sgml-omittag:t
76+
sgml-shorttag:t
77+
sgml-minimize-attributes:nil
78+
sgml-always-quote-attributes:t
79+
sgml-indent-step:1
80+
sgml-indent-data:t
81+
indent-tabs-mode:nil
82+
sgml-parent-document:nil
83+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
84+
sgml-exposed-tags:nil
85+
sgml-local-catalogs:nil
86+
sgml-local-ecat-files:nil
87+
End:
88+
vim600: syn=xml fen fdm=syntax fdl=2 si
89+
vim: et tw=78 syn=sgml
90+
vi: ts=1 sw=1
91+
-->

reference/dom/dom/tokenlist/count.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<refentry xml:id="dom-tokenlist.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
<refnamediv>
4+
<refname>Dom\TokenList::count</refname>
5+
<refpurpose>Returns the number of tokens in the list</refpurpose>
6+
</refnamediv>
7+
8+
<refsect1 role="description">
9+
&reftitle.description;
10+
<methodsynopsis role="Dom\\TokenList">
11+
<modifier>public</modifier> <type>int</type><methodname>Dom\TokenList::count</methodname>
12+
<void/>
13+
</methodsynopsis>
14+
<simpara>
15+
Returns the number of tokens in the list.
16+
</simpara>
17+
</refsect1>
18+
19+
<refsect1 role="parameters">
20+
&reftitle.parameters;
21+
&no.function.parameters;
22+
</refsect1>
23+
24+
<refsect1 role="returnvalues">
25+
&reftitle.returnvalues;
26+
<simpara>
27+
The number of tokens in the list.
28+
</simpara>
29+
</refsect1>
30+
</refentry>
31+
<!-- Keep this comment at the end of the file
32+
Local variables:
33+
mode: sgml
34+
sgml-omittag:t
35+
sgml-shorttag:t
36+
sgml-minimize-attributes:nil
37+
sgml-always-quote-attributes:t
38+
sgml-indent-step:1
39+
sgml-indent-data:t
40+
indent-tabs-mode:nil
41+
sgml-parent-document:nil
42+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
43+
sgml-exposed-tags:nil
44+
sgml-local-catalogs:nil
45+
sgml-local-ecat-files:nil
46+
End:
47+
vim600: syn=xml fen fdm=syntax fdl=2 si
48+
vim: et tw=78 syn=sgml
49+
vi: ts=1 sw=1
50+
-->
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<refentry xml:id="dom-tokenlist.getiterator" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
<refnamediv>
4+
<refname>Dom\TokenList::getIterator</refname>
5+
<refpurpose>Returns an iterator over the token list</refpurpose>
6+
</refnamediv>
7+
8+
<refsect1 role="description">
9+
&reftitle.description;
10+
<methodsynopsis role="Dom\\TokenList">
11+
<modifier>public</modifier> <type>Iterator</type><methodname>Dom\TokenList::getIterator</methodname>
12+
<void/>
13+
</methodsynopsis>
14+
<simpara>
15+
Returns an iterator over the token list.
16+
</simpara>
17+
</refsect1>
18+
19+
<refsect1 role="parameters">
20+
&reftitle.parameters;
21+
&no.function.parameters;
22+
</refsect1>
23+
24+
<refsect1 role="returnvalues">
25+
&reftitle.returnvalues;
26+
<simpara>
27+
An iterator over the token list.
28+
</simpara>
29+
</refsect1>
30+
</refentry>
31+
<!-- Keep this comment at the end of the file
32+
Local variables:
33+
mode: sgml
34+
sgml-omittag:t
35+
sgml-shorttag:t
36+
sgml-minimize-attributes:nil
37+
sgml-always-quote-attributes:t
38+
sgml-indent-step:1
39+
sgml-indent-data:t
40+
indent-tabs-mode:nil
41+
sgml-parent-document:nil
42+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
43+
sgml-exposed-tags:nil
44+
sgml-local-catalogs:nil
45+
sgml-local-ecat-files:nil
46+
End:
47+
vim600: syn=xml fen fdm=syntax fdl=2 si
48+
vim: et tw=78 syn=sgml
49+
vi: ts=1 sw=1
50+
-->

0 commit comments

Comments
 (0)