I'd like to include documentation with my F# functions. As a new user, I recently discovered the XML tags built into F#; that information for those tags can be found here.
My problem is that the param tags don't seem to do anything in the mouse-over window that pops up. For example, this function, with simple XML tags:
//A simple function for StackOverflow question
/// <summary> A test function to post to StackOverflow that doesn't do much at all.</summary>
/// <param name=" x "> A string to pass to the function.</param>
let printString (x: string) =
printfn "This is what you input into the function: %s" x
produces this mouse-over:
I would have expected the parameter x to have been defined in this mouse-over pop-up. Is the tag incorrect? If so, what does the tag need to be for the parameter names to be included in the intellisense pop-up?
Thanks for your comments and help.
The tag is correct, but for whatever reason, these popups just don't list the parameters. For what it's worth, this works the same way in C#.
You can, however, get it to work like it does in C# if you start typing your invocation in C# style:
Related
The documentation at
http://fsharp.github.io/FSharp.Data/library/HtmlProvider.html
claims the following;
"The generated type provides a type space of tables that it has managed to parse out of the given HTML Document. Each type's name is derived from either the id, title, name, summary or caption attributes/tags provided. If none of these entities exist then the table will simply be named Tablexx where xx is the position in the HTML document if all of the tables were flatterned out into a list. "
I am trying to parse the following url
optionsdata = = HtmlProvider<"http://finance.yahoo.com/q/op?s=DDD+Options">
I do not see any Tablexx... types. Any help is appreciated and Thanks in advance. When I view source there are /table tags and there certainly are tables on the html page.
It looks like Yahoo does not send you the page with the same content that you can see in a web browser when you make a plain GET request from a script. This is why the type provider cannot see the tables - they are actually missing in the HTML that gets to the type provider. You can see this by looking at the Html that the type provider gets when you load the page using it:
type DDD = HtmlProvider<"http://finance.yahoo.com/q/op?s=DDD+Options">
DDD.GetSample().Html |> printfn "%A"
As a fix, you can view the source code in a browser, save it in a local file and then pass that to the type provider. Using this, I was able to write the following code:
type DDD = HtmlProvider<"c:/temp/yahoo.html">
let ddd = DDD.GetSample()
for r in ddd.Tables.Table1.Rows do
printfn "%s" r.``Contract Name``
The GetSample method just loads the file from the file system. I assume you want to parse live web pages - for that, you'll need to figure out how the get the right HTML from Yahoo (presumably, by setting some HTTP headers and cookies). Then you can call DDD.Parse(html) to load your actual data.
Here the a suggested pattern for using Intl.message I have seen everywhere:
final String learnMoreLabel = _learnMoreLabel; String get
_learnMoreLabel => Intl.message('Learn more',
name: 'HelpContentBase__learnMoreLabel',
desc: 'The label for a link or button which takes the user to the '
'Google Help Center to read more information on a topic.');
Why can't I just write:
final String learnMoreLabel = Intl.message('Learn more',
name: 'HelpContentBase__learnMoreLabel',
desc: 'The label for a link or button which takes the user to the '
'Google Help Center to read more information on a topic.');
Why does it need to be wrapped in the getter? I found this in the docs:
Use this for a message that will be translated for different locales.
The expected usage is that this is inside an enclosing function that
only returns the value of this call and provides a scope for the
variables that will be substituted in the message.
but it doesn't say why.
The short answer is that for that example it probably could be written that way, but it breaks down when there are parameters to the message.
What happens with Intl messages is that the a preprocessor runs over the program and finds all the occurrences of Intl.message and writes them to a file. That file gets sent for translation, and then the translations are run through another program and generate Dart code for each language, which is reachable via the messages_all.dart import.
When you call Intl.message at runtime it looks up the current locale (using the name as a key) and delegates to the appropriate translation, passing along any parameters (via the "args" argument).
When the comment says "provides a scope" it really means that the only things that are allowed to be used in the message are the variables that are provided as arguments to the enclosing function. When there aren't any arguments we could allow the enclosing function to be omitted. It would mean making the parser smart enough to recognize that pattern as well.
As an aside: I don't love the pattern of calling the method once and assigning to a final variable. It sets up a potential race condition between locale initialization and variable initialization and it means the locale can't change at runtime. However, I understand when we have frameworks like Angular that are calling it and comparing the result on every frame that it gets expensive to actually call the function every time.
Another aside: When there are no parameters you can omit the name. It will use the text as a name. When there are parameters the text is an interpolation so it can't use that as the name.
I am facing problem with the query parameters if they are in camelCase format.
for ex : http://localhost:9000/api/hello?personName=test
This format doesnt work with the Swagger UI. Swagger is not able to pickup any parameter defined in camelCase. It shows error "missing required params: presonName".
Hope this is clear now.
Adding one more screen shot with error
thanks
Wierd but true. I ended up finding something which is a very rare case. As you can see in the screen shot, I was using nodeType as a parameter and to my surprise, the word nodeType is a reserved word in "document" object of html. and thats the reason it creates a problem. I just changed the nodeType to nodeTypeStr and it works fine for me. But still it will be good if Swagger developers take care of handling the reserved words.
I have two <p:dailog>s and based on the condition of a bean property I want to show one of them. I have used the following code
onclick="#{empty groupBean.selectionGroup?dialog_empty.show():groupDialog.show()}"
But it is not working as it says there is an error in EL expression. I am not sure where the error is. Am I doing it the correct way?
You're treating JavaScript code as part of the EL expression. This would only result in a syntax error because EL cannot find #{dialog_empty} nor #{groupDialog} in the scope. You have to treat JavaScript code as strings by quoting them because they ultimately needs to be written to the HTML response as-is:
onclick="#{empty groupBean.selectionGroup ? 'dialog_empty.show()' : 'groupDialog.show()'}"
I have hashmap that was created on a page using the struts2 <s:set> tag. It looks something like this
<s:set var="mymap" value="#request.mymap"/>
At some point in the page, i need to get a value from the hashmap based upon a key, and i want to do it using OGNL.
The key is generated based upon some logic, which i store using another <s:set> tag. Something like this
<s:set var="mykey" value="1">
I need to get a value from the hashmap using this key. And I need to display it.
How do I simply call the get function on the hashmap?
I tried this
<s:property value="#mymap[#mykey]"/>
and this
<s:property value="#mymap[%{#mykey}]"/>
and this
<s:property value="%{#mymap[%{#mykey}}]"/>
The third one obviously does not work because of the nesting problem.
But the same nesting logic is applicable to the second case as well, due to the manner the value attribute is handled. However none seem to work for me.
The issue here is that my key is unknown. It is a dynamically generated string based upon some pattern. I need to access the object stored in the hashmap using this dynamic key. And due to the inability of nesting ognl, I am in a fix.
I suppose the issue is very simple. I almost feel that I get it, but somehow the solution eludes me.
I suppose I was using a different version of struts wherein using the %{} was required for the expression to be evaluated. I changed the jar files now.
This is what did the job for me:
<s:property value="#mymap.[#mykey2]"/>
My problem was coming because I was trying to use it in a href for a s:a tag. And without the %{} operator, the expression was not being evaluated.
So, i guess, i was right in the beginning itself. Rest of the time, it was just me being silly. :>
Update:
I wrote a blog post on the issue, in case anyone is interested.
http://mycodefixes.blogspot.com/2010/11/struts-2-creating-and-accessing-maps.html