Index: trunk/extensions/LabeledSectionTransclusion/lst.php |
— | — | @@ -80,7 +80,15 @@ |
81 | 81 | /** |
82 | 82 | * Handle recursive substitution here, so we can break cycles, and set up |
83 | 83 | * return values so that edit sections will resolve correctly. |
84 | | - **/ |
| 84 | + * @param Parser $parser |
| 85 | + * @param Title $title of target page |
| 86 | + * @param string $text |
| 87 | + * @param string $part1 Key for cycle detection |
| 88 | + * @param int $skiphead Number of source string headers to skip for numbering |
| 89 | + * @return mixed string or magic array of bits |
| 90 | + * @todo handle mixed-case </section> |
| 91 | + * @private |
| 92 | + */ |
85 | 93 | function wfLst_parse_($parser, $title, $text, $part1, $skiphead=0) |
86 | 94 | { |
87 | 95 | // if someone tries something like<section begin=blah>lst only</section> |
— | — | @@ -109,12 +117,28 @@ |
110 | 118 | # And now, the labeled section transclusion |
111 | 119 | ############################################################## |
112 | 120 | |
113 | | -///The section markers aren't paired, so we only need to remove them. |
| 121 | +/** |
| 122 | + * Parser tag hook for <section>. |
| 123 | + * The section markers aren't paired, so we only need to remove them. |
| 124 | + * |
| 125 | + * @param string $in |
| 126 | + * @param array $assocArgs |
| 127 | + * @param Parser $parser |
| 128 | + * @return string HTML output |
| 129 | + */ |
114 | 130 | function wfLstNoop( $in, $assocArgs=array(), $parser=null ) { |
115 | 131 | return ''; |
116 | 132 | } |
117 | 133 | |
118 | | -///Generate a regex to match the section(s) we're interested in. |
| 134 | +/** |
| 135 | + * Generate a regex to match the section(s) we're interested in. |
| 136 | + * @param string $sec Name of target section |
| 137 | + * @param string $to Optional name of section to end with, if transcluding |
| 138 | + * multiple sections in sequence. If blank, will assume |
| 139 | + * same section name as started with. |
| 140 | + * @return string regex |
| 141 | + * @private |
| 142 | + */ |
119 | 143 | function wfLst_pat_($sec, $to) |
120 | 144 | { |
121 | 145 | $to_sec = ($to == '')?$sec : $to; |
— | — | @@ -128,15 +152,34 @@ |
129 | 153 | "$ws\/?>/s"; |
130 | 154 | } |
131 | 155 | |
132 | | -///Count headings in skipped text; the $parser arg could go away in the future. |
| 156 | +/** |
| 157 | + * Count headings in skipped text. |
| 158 | + * |
| 159 | + * Count skipped headings, so parser (as of r18218) can skip them, to |
| 160 | + * prevent wrong heading links (see bug 6563). |
| 161 | + * |
| 162 | + * @param string $text |
| 163 | + * @param int $limit Cutoff point in the text to stop searching |
| 164 | + * @return int Number of matches |
| 165 | + * @private |
| 166 | + */ |
133 | 167 | function wfLst_count_headings_($text,$limit) |
134 | 168 | { |
135 | | - //count skipped headings, so parser (as of r18218) can skip them, to |
136 | | - //prevent wrong heading links (see bug 6563). |
137 | 169 | $pat = '^(={1,6}).+\1\s*$'; |
138 | 170 | return preg_match_all( "/$pat/im", substr($text,0,$limit), $m); |
139 | 171 | } |
140 | 172 | |
| 173 | +/** |
| 174 | + * Fetches content of target page if valid and found, otherwise |
| 175 | + * produces wikitext of a link to the target page. |
| 176 | + * |
| 177 | + * @param Parser $parser |
| 178 | + * @param string $page title text of target page |
| 179 | + * @param (out) Title $title normalized title object |
| 180 | + * @param (out) string $text wikitext output |
| 181 | + * @return string bool true if returning text, false if target not found |
| 182 | + * @private |
| 183 | + */ |
141 | 184 | function wfLst_text_($parser, $page, &$title, &$text) |
142 | 185 | { |
143 | 186 | $title = Title::newFromText($page); |
— | — | @@ -161,7 +204,16 @@ |
162 | 205 | } |
163 | 206 | } |
164 | 207 | |
165 | | -///section inclusion - include all matching sections |
| 208 | +/** |
| 209 | + * Parser function hook for '#lst:' |
| 210 | + * section inclusion - include all matching sections |
| 211 | + * |
| 212 | + * @param Parser $parser |
| 213 | + * @param string $page Title text of target page |
| 214 | + * @param string $sec Named section to transclude |
| 215 | + * @param string $to Optional named section to end at |
| 216 | + * @return mixed wikitext output |
| 217 | + */ |
166 | 218 | function wfLstInclude($parser, $page='', $sec='', $to='') |
167 | 219 | { |
168 | 220 | if (wfLst_text_($parser, $page, $title, $text) == false) |
— | — | @@ -182,8 +234,18 @@ |
183 | 235 | //wfDebug("wfLstInclude: skip $headings headings"); |
184 | 236 | return wfLst_parse_($parser,$title,$text, "#lst:${page}|${sec}", $headings); |
185 | 237 | } |
186 | | - |
187 | | -///section exclusion, with optional replacement |
| 238 | + |
| 239 | +/** |
| 240 | + * Parser function hook for '#lstx:' |
| 241 | + * section exclusion, with optional replacement |
| 242 | + * |
| 243 | + * @param Parser $parser |
| 244 | + * @param string $page Title text of target page |
| 245 | + * @param string $sec Named section to transclude |
| 246 | + * @param string $repl Optional wikitext to use to fill in the excluded section |
| 247 | + * @param string $to Optional named section to end at |
| 248 | + * @return mixed wikitext output |
| 249 | + */ |
188 | 250 | function wfLstExclude($parser, $page='', $sec='', $repl='',$to='') |
189 | 251 | { |
190 | 252 | if (wfLst_text_($parser, $page, $title, $text) == false) |