Welcome Guest, Not a member yet? Register   Sign In
Help documenting 3 new functions for CI 1.5.5
#1

[eluser]Derek Allard[/eluser]
Hey all.

We're ramping up for CI 1.5.5, and just adding a bunch of things in. If you're anxiously looking forward to the release and want to help, I could use a hand on something. The string helper (in the SVN) has 3 new functions: strip_quotes(), quotes_to_entities(), reduce_multiples().

The help I need is
1) Test them, just make sure they behave
2) I need a hand writing the documentation for these. If someone wanted to take a stab at writing the user_guide writeup for them, I'd greatly appreciate it. Here's a template
Code:
<h2>strip_quotes()</h2>
<p>Explanation of what it does. Example:</p>
<code>example code here, as simple as possible.</code>
<p>Any summary info goes here, including options, and more code examples if needed.
Code examples go in <code> tags please.</p>
#2

[eluser]aart-jan[/eluser]
Some docs for the strip_quotes function:

Code:
<h2>strip_quotes()</h2>
<p>Removes single and double quotes from a string. Example:</p>
<code>$string="Joe's \"dinner\"";
$string=strip_quotes($string); //results in "Joes dinner"</code>
<p></p>
#3

[eluser]aart-jan[/eluser]
Some docs for the quotes_to_entities function:

Code:
<h2>quotes_to_entities()</h2>
<p>Converts single and double quotes in a string to the corresponding HTML entities. Example:</p>
<code>$string="Joe's \"dinner\"";
$string=quotes_to_entities($string); //results in "Joe's &quot;dinner&quot;"
</code>
<p></p>
#4

[eluser]zdknudsen[/eluser]
Ah, beat me to it. I take it you are gonna document the last one as well.

Anyway I'd like to point out that the quotes_to_entities only turns escaped quotes into entities.

This'll fix it:
Code:
return str_replace(array("'",'"'), array("'","&quot;"), $str);
#5

[eluser]aart-jan[/eluser]
Some docs for the reduce_multiples function:

Code:
<h2>reduce_multiples()</h2>
<p>Reduces multiple instances of a particular character occuring directly after each other. Example:</p>
<code>
$string="Fred, Bill,, Joe, Jimmy";
$string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"
</code>
<p>The function accepts the following parameters:
<code>reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string)</code>

The first parameter contrains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced.
The third parameter is False by default. If it it's to true it will remove occurences of the character at the beginning and the end of the string. Example:

<code>
$string=",Fred, Bill,, Joe, Jimmy,";
$string=reduce_multiples($string,",",true); //results in "Fred, Bill, Joe, Jimmy"
</code>
</p>
#6

[eluser]aart-jan[/eluser]
[quote author="Zacharias Knudsen" date="1196971452"]Ah, beat me to it. I take it you are gonna document the last one as well.
[/quote]
Yeah, sorry for the doubleposting but this way nobody would do double work... Wink I'm not native English so if someone could improve the docs be my guest! Smile
#7

[eluser]zdknudsen[/eluser]
The double posting was a good way to go, I had just finished the first one when i updated and saw your post. If you hadn't posted I might have done twice the work, without reason Wink

The only suggestions i have is to use the same spacing as the rest of the user guide (e.g. space before and after equal signs, space after the commas that separate the parameter and space after // in comments.
#8

[eluser]BoltClock[/eluser]
Not about documentation, but I found that reduce_multiples() wasn't escaping metacharacters that would break preg_replace(), I've already added preg_quote() to the function, should I commit it to the repository now?

And I was about to help out in docs but you guys have already done it so...

Anyway, looking forward to CI 1.5.5's imminent (hopefully) release!
#9

[eluser]zdknudsen[/eluser]
I somehow doubt that the public SVN allows you to commit Tongue
#10

[eluser]BoltClock[/eluser]
[quote author="Zacharias Knudsen" date="1196992358"]I somehow doubt that the public SVN allows you to commit Tongue[/quote]

Oh, I didn't know that. Guess I need to learn SVN a bit more before saying anymore about it :down:




Theme © iAndrew 2016 - Forum software by © MyBB