r23229 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23228‎ | r23229 | r23230 >
Date:15:35, 22 June 2007
Author:brion
Status:old
Tags:
Comment:
Add some doc comments...
Modified paths:
  • /trunk/extensions/LabeledSectionTransclusion/lst.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LabeledSectionTransclusion/lst.php
@@ -80,7 +80,15 @@
8181 /**
8282 * Handle recursive substitution here, so we can break cycles, and set up
8383 * 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+ */
8593 function wfLst_parse_($parser, $title, $text, $part1, $skiphead=0)
8694 {
8795 // if someone tries something like<section begin=blah>lst only</section>
@@ -109,12 +117,28 @@
110118 # And now, the labeled section transclusion
111119 ##############################################################
112120
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+ */
114130 function wfLstNoop( $in, $assocArgs=array(), $parser=null ) {
115131 return '';
116132 }
117133
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+ */
119143 function wfLst_pat_($sec, $to)
120144 {
121145 $to_sec = ($to == '')?$sec : $to;
@@ -128,15 +152,34 @@
129153 "$ws\/?>/s";
130154 }
131155
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+ */
133167 function wfLst_count_headings_($text,$limit)
134168 {
135 - //count skipped headings, so parser (as of r18218) can skip them, to
136 - //prevent wrong heading links (see bug 6563).
137169 $pat = '^(={1,6}).+\1\s*$';
138170 return preg_match_all( "/$pat/im", substr($text,0,$limit), $m);
139171 }
140172
 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+ */
141184 function wfLst_text_($parser, $page, &$title, &$text)
142185 {
143186 $title = Title::newFromText($page);
@@ -161,7 +204,16 @@
162205 }
163206 }
164207
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+ */
166218 function wfLstInclude($parser, $page='', $sec='', $to='')
167219 {
168220 if (wfLst_text_($parser, $page, $title, $text) == false)
@@ -182,8 +234,18 @@
183235 //wfDebug("wfLstInclude: skip $headings headings");
184236 return wfLst_parse_($parser,$title,$text, "#lst:${page}|${sec}", $headings);
185237 }
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+ */
188250 function wfLstExclude($parser, $page='', $sec='', $repl='',$to='')
189251 {
190252 if (wfLst_text_($parser, $page, $title, $text) == false)

Status & tagging log