How to document multiple errors with #throws in YUIdoc / jsdoc? - jsdoc

According to the documentation of YUIdoc (which seems to be in this case equivalent to jsdoc) there is a #throws tag to document a potentially thrown error.
Specifies an error which method throws. A #throws tag has the
structure #throws {type} description. The {type} is optional.
In my case there are several checks in a function which can throw an error so I would like to list them with #throws. But you can not have more than one #throws tag. So how can I put a list of potentially thrown errors in this tag?

I know it is old. But as this is the first google result but does not have a proper answer I will show you the solution I found here: https://stackoverflow.com/a/29720979/8466273
Just use multiple #throws:
/**
* -- other definitions --
* #throws {RangeError} must be in range 0 to 10
* #throws {URIError} wrong URI given
* -- other definitions --
*/

Finally I can answer the question myself:
Just make it a list. If you like you can change the look of the text via style tag - just add it to the <ul>
* #throws {}
* <ul >
* <li> {exception} Condition 1</li>
* <li> {exception} Condition 2/li>
* <li> {exception} Condition 3</li>
* </ul>

Related

What is the background of allowAllProperties, why is it necessary here?

I have a form with a parameter that is mapped to an object storage. In a template I have form that sets this parameter with a list of checkboxes. Heres an overview of the action in the controller and the template.
Controller
/**
* action list
* #param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Redacted\Productfinder\Domain\Model\Category> $categories
* #return void
*/
public function searchAction($categories=NULL) {
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(func_get_args());
...
}
Template
<f:for each="{categories}" as="option">
<li class="category-{option.uid}" data-filter="{option.uid}">
<label for="checkbox-category-{option.uid}">
<f:form.checkbox name="categories" multiple="true" id="checkbox-category-{option.uid}" value="{option.uid}" checked="{x:condition.iterator.contains(haystack:'{filter.categories}', needle:'{option}', then:'checked')}" />
<span class="title">{option.title}
</label>
</li>
</f:for>
This, so far, works like a charm. I'm now trying to set the $categories parameter with a link, but that doesn't work. I have a f:for loop with the categories.
If I set the Parameter to the single object like so, it is ignored. No error message, Extbase just ignores the value.
<f:link.action action="list" arguments="{categories:category}">{category.title}</f:link.action>
If I set the parameter to an array with that value, like so
<f:link.action action="list" arguments="{categories:{0:'{category}'}}">{category.title}</f:link.action>
Extbase tells me, that the Parameter cannot be mapped.
#1297759968: Exception while property mapping at property path "": It is not allowed to map property "0"
I've managed to figure out, that I can tell Extbase to allow the property mappging, and then resolve the raw uids into extbase objects, like so
$propertyMappingConfiguration = $this->arguments->getArgument($property)->getPropertyMappingConfiguration();
$propertyMappingConfiguration->allowAllProperties();
I'd like to understand the background of this, why is this necessary to allow this for GET parameters, when it just works for POST? Am I doing something wrong, or is this by design?
This is indeed by design. If you use <f:form.textfield..... it isn't needed to set it expliciet like you do.
This is to prevent that unwanted items are past/persisted because someone changed the form manually.
So it's a security thing

How to disable automated encoding of special characters in fluid partials (TYPO3)

Should be simple enough. I'm trying to add an input field to a fluid partial in the extension "yag" (yet another gallery).
Input: <f:form.textfield id="live-filter" name="test" />
Output: <input id="live-filter" type="text" name="test" />
Somehow the code get's filtered along the way, but I don't know why.
TYPO3 v. 6.2
YAG v. 3.2.1
Edit: A wild guess would be some output filtering in TYPO3 itself, but where? I didn't set anything by purpose.
You need to traverse the path upwards to check if there is any fluid tag wrapped around it, that does escaping. In general, all tags do escaping.
Also check the code around <f:render partial....
It could also be that the TypoScript code that does calls the fluid template, has a .htmlspecialchars = 1 set.
Since TYPO3 8 there is another pitfall: Custom Viewhelpers do htmlspecialchars on the output unless told otherwise. The solution is:
<?php
namespace Vendor\ArTest\ViewHelpers;
class YourViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper{
/**
* As this ViewHelper renders HTML, the output must not be escaped.
*
* #var bool
*/
protected $escapeOutput = false;
As of TYPO3 ver. 9.5 and up to ver. 10.4 you could also wrap the output in the Fluid template into <f:format.htmlentitiesDecode> Tags like this:
<f:format.htmlentitiesDecode>
<f:form.textfield id="live-filter" name="test" />
</f:format.htmlentitiesDecode>
Further information on this can be found in the TYPO3 View Helper Reference.

Output examples with html

I am wanting to output examples which has HTML within it such as
* #example
* <div ng-app="reportingBuilderApp">
* <div ng-view></div>
* </div>
But at the moment it renders it "safely" as HTML however I want it as text, at the moment I am needing to write the example as below (which is much more tedious and ugly in the actual JS)
* #example
* <div ng-app="reportingBuilderApp">
* <div ng-view></div>
* </div>
Is there any way of sorting JSDoc to prevent the HTML from being output "safely" automatically?
Using version 3.3.0-alpha4, with the following test file:
/**
* #example
* <div ng-app="reportingBuilderApp">
* <div ng-view></div>
* </div>
*/
function foo() {
}
I get an example that shows up correctly in the output of jsdoc.
As the name suggests, 3.3.0-alpha4 is still in alpha. To my knowledge there is no version previous to 3.3.0-alpha... which has the fix for this problem, and no workaround for it. The bug report that prompted the fix is here.
There is no way to get around this. You will need to use HTML escape code if you want to show the < and > symbols in the final HTML JSDoc pages.

jquery .html() returning null in ie7

On click li element i am getting the current element value and appending it into another div dynamically.Its working fine in all browsers.But returning null in IE7.I don`t the reason that why its happening?Please can any one give me a solution for this..Part of the code only i pasted here.
Sample code:
////////////.//This line returning null in IE7./////////////////
$('#pagelink_a #pagelinkli_'+tab_lastid_val).html()
(tab_lastid_val value can be a 1 or 2 or 3.Clixked li element value comes here)
<div class="pagelink">
<div id="pagelink_a">
<ul>
/******** all li element are clickable***********/
<li id="pagelinkli_1"><a>Google</a></li>
<li id="pagelinkli_2"><a>Chrome</a></li>
<li id="pagelinkli_3"><a>Firefox</a></li>
</ul>
</div>
</div?
try this:
$('#pagelink_a').find('li[id=pagelinkli_'+tab_lastid_val']').html();
code is not tested but i think it should work.
Given your html layout, your parent div is .pagelink not #pagelink_a , so replace your following line:
$('#pagelink_a #pagelinkli_'+tab_lastid_val).html()
for this one:
$('.pagelink #pagelinkli_'+tab_lastid_val).html()
Just use
$('#pagelinkli_'+tab_lastid_val).html()
The # tag identifies an ID which only a single element may have. There is no need to have anything preceding it. You also labeled the previous class as id, which is wrong. I don't know how your other browsers managed to get anything.
Although bit off topic, it may be better to actually drop IE7 support entirely. Due to small user base and decreasing popularity, it may be costing you more money by support it than to not support it.
Try instead of html() , and try append().
For example
$('#ID').append('Your content');

In Selenium IDE how can you select an option by index in a dropdown menu?

The problem is the option labels change and so I cant grab by label. I need to grab by say option[0]
any idea?
I'm using Selenium IDE (Firefox), this is the piece im asking about:
<tr>
<td>select</td>
<td>dateRangeString</td>
<td>index=1</td>
</tr>
the last TD there is the VALUE field in the IDE,
I already am targeting the select element, but i need to simulate the user selecting the first option. The only way I see to do this is by using LABEL="string" in the VALUE part of the IDE, but string is dynamic so thats not going to work!
you can select it by using the XPath //select/option[index].
Remember that XPath is a 1 based index by standard.
Edit After Question was updated
You can use a number of different ways to select an option from within a select. Below has been copied from the Selenium IDE on how to create option locators. To select the first item it would be index=0
select(selectLocator, optionLocator)
Arguments:
* selectLocator - an element locator identifying a drop-down menu
* optionLocator - an option locator (a label by default)
Select an option from a drop-down using an option locator.
Option locators provide different ways of specifying options of an HTML
Select element (e.g. for selecting a
specific option, or for asserting that
the selected option satisfies a
specification). There are several
forms of Select Option Locator.
* label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)
o label=regexp:^[Oo]ther
* value=valuePattern: matches options based on their values.
o value=other
* id=id: matches options based on their ids.
o id=option1
* index=index: matches an option based on its index (offset from zero).
o index=2
If no option locator prefix is provided, the default behaviour is to
match on label.
Instead of using label="", try using index="1" (to select the first element). Selenium offers label="", id="", value="", and index="" for this sort of cases. For more details, see:
http://release.seleniumhq.org/selenium-core/0.8.0/reference.html
Tricky, but the "type" command helped me here:
<tr>
<td>type</td>
<td>id=numStuff</td>
<td>1</td>
</tr>
The corresponding html looks like this (except the #id and #name attributes)
<select id="numStuff" name="numStuff">
<option selected= value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
I'm wondering if it works for option values longer than 1 keystroke. At least, it's good for the time being.
In C#, i solved this by using:
selenium.Select("id=yourID", "index="+i.ToString());
In selenium IDE I used:
Command: select
Target: XPath target ending in select (not option). XPath can be obtained with FireBug and FirePath.
Value: E.G. "Texas"
or whatever value pattern you require
For example:
select | Locator | index=1 |
It worked for me.