Template:Javadoc:SE/doc: Difference between revisions

Content deleted Content added
m fixing lint errors
m added a link to Template:Javadoc as well
 
(9 intermediate revisions by 5 users not shown)
Line 1:
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
{{nosubst}}
 
{{esoteric}}
Template for creating an external link into the [[Javadoc]] for a class in the current version of the [[Java SE]] API. This template should be used instead of an explicit URL to allow the link to be automatically updated to the latest API when this template is updated.
 
Please update [[Template:Javadoc:SE/Home_URL]] to update the Java version that this link sends users to.
'''Do not [[Wikipedia:Template substitution|subst]] this template.'''
 
If you would prefer to include a link to the javadocs of a specified version of Java, see [[Template:Javadoc]] (supports versions from JDK 11).
 
== Usage ==
Line 14 ⟶ 15:
! '''Type this''' !! '''To get this'''
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE}}</nowiki></ttsyntaxhighlight> || {{Javadoc:SE}}
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|java/lang|Object}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|java/lang|Object}}
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|java/lang|Object|clone()}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|java/lang|Object|clone()}}
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|package=java.lang|java/lang}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|package=java.lang|java/lang}}
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|package=java.lang|java/lang|Object}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|package=java.lang|java/lang|Object}}
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|package=java.lang|java/lang|Object|clone()}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|package=java.lang|java/lang|Object|clone()}}
|-
| <syntaxhighlight lang="wikitext" inline>{{Javadoc:SE|jdk/javadoc/doclet|StandardDoclet|module=jdk.javadoc}}</syntaxhighlight>
| {{Javadoc:SE|jdk/javadoc/doclet|StandardDoclet|module=jdk.javadoc}}
|}
 
In the above example, <ttcode>clone()</ttcode> can be any member documented in the [[Javadoc]] that isn't a class or interface, so <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|java/lang|System|out}}</nowiki></ttsyntaxhighlight> produces {{Javadoc:SE|java/lang|System|out}}. For a class or interface member, the class name is <ttcode>OuterClass.InnerClass</ttcode>, so <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|java/lang|Character.Subset}}</nowiki></ttsyntaxhighlight> produces {{Javadoc:SE|java/lang|Character.Subset}}.
 
The Javadoc URLs don't include the [[generic programming|generic]] parameterized types. To get the type parameters to display, specify a <ttcode>class</ttcode> and/or <ttcode>member</ttcode> parameter to the template to override the name of the displayed class and/or member name. Note that the parameterized type notation uses angle brackets (<ttcode><</ttcode> and <ttcode>></ttcode>), so type parameter names that match [[HTML tag|HTML markup tags]] need to use the [[character encodings in HTML|character encodings]] <ttcode>&amp;lt;</ttcode> for <ttcode><</ttcode> and <ttcode>&amp;gt;</ttcode> for <ttcode>></ttcode>.
 
:{| class="wikitable"
! '''Type this''' !! '''To get this'''
|-
| <tt><nowikisyntaxhighlight lang="wikitext">{{Javadoc:SE|class=Class<T>|java/lang|Class}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|class=Class<T>|java/lang|Class}}
|-
| <syntaxhighlight lang="wikitext">{{Javadoc:SE|class=Class<T>|
| <tt><nowiki>{{Javadoc:SE|class=Class<T>|</nowiki><br><nowiki>member=asSubclass(Class&amp;lt;U&amp;gt;)|</nowiki><br><nowiki>java/lang|Class|asSubclass(java.lang.Class)}}</nowiki></tt>
member=asSubclass(Class&lt;U&gt;)|
java/lang|Class|asSubclass(java.lang.Class)}}</syntaxhighlight>
| {{Javadoc:SE|class=Class<T>|member=asSubclass(Class&lt;U&gt;)|java/lang|Class|asSubclass(java.lang.Class)}}
|-
| <tt><nowikisyntaxhighlight lang="wikitext">{{Javadoc:SE|package=java.lang|class=Class<T>|</nowiki><br><nowiki>java/lang|Class}}</nowiki></tt>
java/lang|Class}}</syntaxhighlight>
| {{Javadoc:SE|package=java.lang|class=Class<T>|java/lang|Class}}
|-
| <tt><nowikisyntaxhighlight lang="wikitext">{{Javadoc:SE|package=java.lang|class=Class<T>|</nowiki><br><nowiki>member=asSubclass(Class&amp;lt;U&amp;gt;)|</nowiki><br><nowiki>java/lang|Class|asSubclass(java.lang.Class)}}</nowiki></tt>
member=asSubclass(Class&lt;U&gt;)|
java/lang|Class|asSubclass(java.lang.Class)}}</syntaxhighlight>
| {{Javadoc:SE|package=java.lang|class=Class<T>|member=asSubclass(Class&lt;U&gt;)|java/lang|Class|asSubclass(java.lang.Class)}}
|}
 
The URL to a method uses the fully-qualified path name of the parameter types. The <ttcode>member</ttcode> parameter can be used to use the simple type name of method parameters, as shown in the preceding table, or even to eliminate the parameters entirely.
 
Finally, if none of the above work for the displayed text, supplying a <ttcode>name</ttcode> parameter allows the entire package/class/member name displayed to be replaced. (However, the <ttcode>name</ttcode> parameter won't override the text displayed when using the <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE}}</nowiki></ttsyntaxhighlight> form.)
 
:{| class="wikitable"
! '''Type this''' !! '''To get this'''
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|name=out|java/lang|System|out}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|name=out|java/lang|System|out}}
|}
Line 69 ⟶ 78:
! '''Type this''' !! '''To get this'''
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|member=indexOf(int, int)|java/lang|String|indexOf(int,%20int)}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|member=indexOf(int, int)|java/lang|String|indexOf(int,%20int)}}
|}
Line 76 ⟶ 85:
! '''Type this''' !! '''To get this'''
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|member=indexOf(int, int)|java/lang|String|indexOf(int,int)}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|member=indexOf(int, int)|java/lang|String|indexOf(int,int)}}
|}
# Including square brackets ([, ]) in the parameter types of method or constructor member arguments seems to break the template. Instead, replace square brackets with their [[numeric character reference]] escape codes, &amp;#91; and &amp;#93;, like this:
::{| class="wikitable"
! '''Type this''' !! '''To get this'''
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE|java/util|Arrays|sort(java.lang.Object&amp;#91;&amp;#93;)}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE|java/util|Arrays|sort(java.lang.Object&#91;&#93;)}}
|-
| <tt><nowikisyntaxhighlight lang="wikitext" inline>{{Javadoc:SE | member=sort(Object&amp;#91;&amp;#93;)|java/util|Arrays|sort(java.lang.Object&amp;#91;&amp;#93;)}}</nowiki></ttsyntaxhighlight>
| {{Javadoc:SE | member=sort(Object&#91;&#93;)|java/util|Arrays|sort(java.lang.Object&#91;&#93;)}}
|}
# Anything which is '''not''' within the [{{Javadoc:SE/Home_URL}}java.base/module-summary.html <code>java.base</code>] module of the Java API '''must''' declare the <code>module</code> parameter to ensure that the user is sent to the correct area of the documentation. If <code>module</code> is not specified, the template will default to <code>java.base</code> - which, if the item in question is not within <code>java.base</code>, will send the reader to a 404 page.
::{| class="wikitable"
! '''Type this''' !! '''To get this'''
|-
| <syntaxhighlight lang="wikitext" inline>{{Javadoc:SE|jdk/javadoc/doclet|StandardDoclet|module=jdk.javadoc}}</syntaxhighlight>
| {{Javadoc:SE|jdk/javadoc/doclet|StandardDoclet|module=jdk.javadoc}}
|-
| <syntaxhighlight lang="wikitext" inline>{{Javadoc:SE|java/awt|Graphics2D|module=java.desktop}}</syntaxhighlight>
| {{Javadoc:SE|java/awt|Graphics2D|module=java.desktop}}
|}
 
Line 95 ⟶ 114:
* [[Template:Javadoc:EE]]
* [[Template:Javadoc:Android]]
* [[Template:Javadoc:SE/Home_URL]]
 
<includeonly>{{Sandbox other||
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
 
Line 107 ⟶ 127:
[[ru:Шаблон:Javadoc:SE]]
 
}}</includeonly>