Javadoc: using #link to link to a description of an interface - hyperlink

I am a technical writer who is editing the Javadoc comments written by our developers. One of the comments was like
/**
* Lorem ipsum dolor sit amet.
* {#link SomeInterface}
*/
When submitted to Jenkins, the build failed with an error like "Unresolved link/see tag" so I made the following change:
/**
* Lorem ipsum dolor sit amet.
* {#link com.example.foo.SomeInterface}
*/
I thought that would have fixed the problem (changing to a fully-qualified interface name), but it is still failing with the same error message.
In reading http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#link the first sentence says
Inserts an in-line link with visible text label that points to the documentation
for the specified package, class or member name of a referenced class.
which specifically says "referenced class" and does not include "interface". How can I #link to the description for a public interface?

Related

Is "Comment" a protected word in the Open API 3.0 spec or Swagger Editor?

I'm currently working on an API spec using the Swagger Editor (v3.1.9) and the Open API 3 specification.
I'm getting some peculiar behavior specifically for a Schema component I have named Comment
Comment:
description: "A comment on an asset or submission"
allOf:
- $ref: "#/components/schemas/Message"
type: object
properties:
parent:
oneOf:
- $ref: "#/components/schemas/Asset"
- $ref: "#/components/schemas/Submission"
In the UI, it renders as (with none of the inheritance from Message)
Comment {
description: A comment on an asset or submission
parent {
oneOf -> {
}
v {
}
}
}
However, if I rename it to anything else, say Commentary it will render fully (with inheritance from Message):
Commentary{
description: A comment on an asset or submission
id string($uuid)
example: f1907c82-2c5f-4f60-8cd9-12647d411822
author User{...}
body string
example: Lorem ipsum dolor sit amet
message_type string
example: DiscussionPost
parent {
oneOf -> Asset{...}
Submission{...}
}
}
The only thing I can think of is that there is somehow a reserved word for Comment in either or both of the Open API spec or Swagger Editor. The main thing I want to know is if this is indeed a bug, or if I should be avoiding using this name (and if that's the case, if there are any others I should avoid)
No, Comment is not a reserved word. Your schema is correct.
The schema rendering issue seems to have been a bug that is now fixed. Your schema is rendered correctly in the latest Swagger Editor.

Regular expression to determine each and every attribute of an anchor tag inside HTML content

I basically wanted the values of each and every attribute. The attributes may be optional and the href may contain HTTP or HTTPS.
A sample anchor tag inside content is:
<a class=\"direct_link\" rel=\"nofollow\" target=\"_blank\" href=\"http://google.com\">link text</a>
Sample HTML content is:
<p><br></p><h1>A beautiful <a class=\"f-link\" rel=\"nofollow\" target=\"_blank\" href=\"fake.com/abc.html\">jQuery</a>; a</h1><h3 class=\"text-light\">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's.</h3><p><br></p><p><br></p>
Don't use a regular expression to try to parse HTML. HTML can be expressed too many ways and still be valid, yet it will break your pattern and code.
The correct way to get the values for the parameters is to use a parser. Nokogiri is the defacto XML/HTML parser for Ruby:
require 'nokogiri'
doc = Nokogiri::HTML::DocumentFragment.parse(' <a class=\"direct_link\" rel=\"nofollow\" target=\"_blank\" href=\"http://google.com\">link text</a>')
That parses the document into a DOM and returns it.
link = doc.at('a')
at finds the first instance using the CSS 'a' selector. (If you want to iterate over them all you can use search, which returns a NodeSet, which is akin to an Array.)
At this point link is a Node, which we can consider to be like a pointer to the <a> tag.
link.to_h # => {"class"=>"\\\"direct_link\\\"", "rel"=>"\\\"nofollow\\\"", "target"=>"\\\"_blank\\\"", "href"=>"\\\"http://google.com\\\""}
That is the link's parameters and their values turned into a hash. Or, you can directly access the parameters, using keys, or their values:
link.values # => ["\\\"direct_link\\\"", "\\\"nofollow\\\"", "\\\"_blank\\\"", "\\\"http://google.com\\\""]
link.keys # => ["class", "rel", "target", "href"]
Or treat it like a hash and iterate over the key/value pairs:
link.each do |k, v|
puts 'parameter: "%s" value: "%s"' % [k, v]
end
# >> parameter: "class" value: "\"direct_link\""
# >> parameter: "rel" value: "\"nofollow\""
# >> parameter: "target" value: "\"_blank\""
# >> parameter: "href" value: "\"http://google.com\""
The advantage to using the parser, is that the HTML format can change and the parser is still able to figure it out, and your code won't care. The following format works just as good as the tag used above:
doc = Nokogiri::HTML::DocumentFragment.parse(' <a
class=\"direct_link\"
rel=\"nofollow\" target=\"_blank\"
href=\"http://google.com\">
link text
</a>')
Try doing that with a pattern.
Well if you want does the stuff in the quotes it would be this:
"([\w:\/.]+)\\"
Test it here
Otherwise if you want the name before the quotes it would be this:
(\w+=\\"[\w:\/.]+\\")
Test it here
This one matches tags without backslashes:
(\w+="[\w:\/.-]+")
Test it here

Binding Sampledata WindowsPhone

I have a simple class with a property List Photos. You know by default in many sample of code you find a sampledata. Each time, it presents a simple property as a string. This sampledata is used to populate the designer and you can see the render without to compile.
So I try to find a way to have a sampledata with a List filled.
I try to use the functionnality from Blend permitting to generate data but it doesn't work with List.
You can see below the code generate. It miss the property List.
And I don't find any documentation explaning clearly the binding in details.
<ViewModels:ItemViewModel xmlns:ViewModels="clr-namespace:RssReader.ViewModels"
Description="Aliquam aenean integer quisque mauris"
Link="Maecenas vivamus"
Title="Praesent curabitur aliquam nullam phasellus"/>
My assumption is I need to add something as
<ViewModels:ItemViewModel xmlns:ViewModels="clr-namespace:RssReader.ViewModels"
Description="Aliquam aenean integer quisque mauris"
Link="Maecenas vivamus"
Title="Praesent curabitur aliquam nullam phasellus"
<Photos x:Key="strings" Type="sys:List"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:String>Photos1</sys:String>
<sys:String>Photos2</sys:String> >
</Photos>
But it's not the correct syntax. Can you provide an help to solve it.
This topic is link to the subject Databinding List<Object> WindowsPhone
Best regards,
Alexandre
Read working with Design and Runtime Data for Windows Phone.

How to translate a dynamic title attribute

I have this kind of translation to make :
<a tal:attributes="href troncon/url;
title string:Cette etape fait partie du troncon ${troncon/nom}"
tal:content="troncon/nom">Canal du centre</a>
You see that I have a dynamic title attribute that I want to be translatable.
I've tried like this :
<a tal:attributes="href troncon/url;
title string:Cette etape fait partie du troncon ${troncon/nom}"
tal:content="troncon/nom"
i18n:attributes="title">Canal du centre</a>
And like this :
<a tal:attributes="href troncon/url;
title string:Cette etape fait partie du troncon ${troncon/nom}"
tal:content="troncon/nom"
i18n:attributes="title"
title="Cette etape fait partie du troncon ${nom}">Canal du centre</a>
But this doesn't work (of course).
Any ideas ?
The result of the tal:attributes call is passed literally to the translation machinery. i18n:attributes matches it's keys against what tal:attributes generates, and if there is a match, the original attribute on the element is ignored (see this I18N article on the Zope 3 wiki.
This means that the result of "Cette etape fait partie du troncon ${troncon/nom}" will be looked up for translation, requiring you to provide translations for each variation of the sentence that can be made with all possible values of troncon/nom.
To get support for proper placeholders in this string you are better off creating a message id in the code that generates the troncon structure and translate it there, presumably in your view. You need:
A message id with the placeholder
Attach the nom value to the message id
Translate this message to the currently selected language
Include the result in your troncon structure
I generally do this is one step:
from zope.i18n import translate
from zope.i18nmessageid import MessageFactory
_ = MessageFactory('yourdomain')
troncon = dict(
...
nom=nom,
nomtitre=translate(
_(u'troncon_nomtitre', default=u'Cette etape fait partie du troncon ${nom}',
mapping=dict(nom=nom)),
context=self.request)
)
Do note that you need a request for the translation function to pick the correct language.
You can always force the translation on context.translate():
tal:attributes="foobar python:context.translate(string, domain='translationdomain')"
http://collective-docs.readthedocs.org/en/latest/i18n/internationalisation.html#manually-translated-message-ids
However, this might be against all best practices.

Parse arbitary user input [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have a database full of messages from a bulletin board. The board uses BB codes as formatting style. I.e.:
I'm not formatted
This is [b]bold[/b] text
Tags can also [i][b]be[/b] nested[/i]
And the [b]nesting [i]can be[/b] rather[/i] ugly
My ultimate goal is to convert these messages to some well formed XML (no discussion here ;) ). I don't want to use regular expression, which will fail at some point (in fact: it does).
First step: parse a message into some kind of internal representation (a graph, a tree, etc.). And I'm stuck at this point. The actual extraction is not that big problem, but the storage is.
How do I represent this kind of markup into some meaningful structure. My problem seems to be similar (or almost identical) to a browser building a DOM from a HTML file. So I think there are some strategies to solve it. I know the solution will not be perfect but im willing to invest a vast amount of time to do build the best possible.
Question: Do you have any tips/hint/comments? Any articles or paper you can recommend? Or a book which discusses these topic? I'm grateful for any input.
And the [b]nesting [i]can be[/b] rather[/i] ugly
I've written a parser very similar to what you are looking to do except that it would throw an error on your fourth example. Something to the effect of "Unexpected end tag [/b] within [i]".
I think that what you want to do is very doable but internally you will want to create a tree as if your original text was:
"And the [b]nesting [i]can be[/i][/b][i] rather[/i] ugly". (I don't think this would be necessary if you didn't need to convert it to XML later. If there were no need to convert to XML you could keep a linked list of text sections where each section is marked with its format combination)
Two possible approaches to this problem come to mind (of course there could be better possibilities). 1) Preprocess and insert the missing end and begin tags where necessary. 2) Build your parse tree and where there are overlapping tags imply the missing ones based on the current context. I think approach number (2) would be simpler and cleaner.
You could model your tree based on a composite pattern where you have an AbstractElement class, a TextElement class that extends AbstractElement, and a Tag class that extends AbstractElement and contains a list of sub-elements of type AbstractElement.
You would start by creating a root Tag instance. You would then call rootTag.parse(text). You would need a scanner that could return 3 types of tokens: text, start-tags, and end-tags. The scanner would allow you to push tokens onto it, which it would return before any normal scanned token. This would allow you to push new start tag tokens on after encountering and dealing with the unexpected end tag. You would also have to know when you are done with input. I'll use a 4th token type for that.
/* methods within class Tag */
public void parse(String text) {
MyScanner scanner = new MyScanner(text);
parse(scanner);
}
/* returns next token */
private Token parse(MyScanner scanner) {
Token firstToken = scanner.getNextToken();
return parse(scanner,firstToken);
}
private Token parse(MyScanner scanner) {
Token firstToken = scanner.getNextToken();
return parse(scanner,firstToken);
}
private Token parse(MyScanner scanner, Token token) {
while (!token.isDone() && !token.isEndTag()) {
if (token.isStartTag()) {
Tag subTag = new Tag(token.getValue());
token = scanner.getNextToken();
token = subTag.parse(scanner,token);
addElement(subTag);
}
else {
TextElement text = new TextElement(token.getValue());
addElement(text);
token = scanner.getNextToken();
}
}
if (token.isEndTag()) {
if (!token.getValue().equals(getName()) {
scanner.push(new Token(Token.START_TAG,token.getValue()));
}
else {
token = scanner.getNextToken();
}
}
return token;
}
So if you were to parse "And the [b]nesting [i]can be[/b] rather[/i] ugly", The following should get created.
rootTag.parse should be adding:
TextElement: "And the "
Tag: "b"
TextElement: "nesting "
Tag: "i"
TextElement: "can be"
(... at this point the odd [/b] is encountered ...)
(... push "i" start tag on the scanner ...)
(... here the [/b] is encountered (again) ...)
Tag: "i" (this was scanned because it had been pushed to the scanner)
TextElement: " rather"
TextElement: " ugly"
Note: Coding within a text area does not lend itself well to testing and debugging. Accept this answer as a hint or a possibility, not as your definate answer.

Resources