Skip to content

Commit efb81c2

Browse files
uschindlercentic9
authored andcommitted
Add documentation about signatures file format. This closes policeman-tools#128
1 parent b8f5cf1 commit efb81c2

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
</loadresource>
322322
</target>
323323

324-
<target name="documentation" depends="maven-descriptor,-get-cli-help">
324+
<target name="documentation" depends="maven-descriptor,-get-cli-help" description="Builds documentation and creates ZIP">
325325
<mkdir dir="${documentation-dir}"/>
326326
<copy todir="${documentation-dir}">
327327
<fileset dir="src/main/docs" excludes="*.xsl" />

src/main/docs/docindex.xsl

+5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
<xsl:text>&#10;</xsl:text>
6666
<xsl:value-of select="$clihelp"/>
6767
</pre>
68+
<h2>Additional documentation</h2>
69+
<ul>
70+
<li><a href="bundled-signatures.html">Bundled Signatures</a></li>
71+
<li><a href="signatures-syntax.html">Syntax of Custom Signatures Files</a></li>
72+
</ul>
6873
</body>
6974
</html>
7075
</xsl:template>

src/main/docs/signatures-syntax.html

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<html>
2+
<!--
3+
* (C) Copyright Uwe Schindler (Generics Policeman) and others.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
-->
17+
<head>
18+
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
19+
<title>Syntax of Custom Signatures Files</title>
20+
</head>
21+
<body>
22+
<h1>Syntax of Custom Signatures Files</h1>
23+
24+
<p><b>Forbidden API Checker</b> allows to define custom signatures files. Depending on
25+
the type of task (Ant, Maven, or Gradle), you can add them via references to
26+
local files from your project directory. Maven also supports to refer to them using
27+
Maven coordinates.</p>
28+
29+
<p>The syntax of those files is: Each line that is not empty, does not start with a
30+
<code>#</code> or <code>@</code> symbol is treated as a signature. The following types
31+
of signatures are supported:</p>
32+
33+
<ul>
34+
<li><em>Class reference:</em> A binary/fully-qualified class name (including package). You may
35+
use the output of <a href="https://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getName()">
36+
Class.getName()</a>. Be sure to use correct name for inner
37+
classes! Example: <code>java.lang.String</code></li>
38+
<li><em>A package/class glob pattern:</em> To forbid all classes from a package, you may use
39+
glob patterns, like <code>sun.misc.**</code> (&quot;<code>**</code>&quot; matches against package
40+
boundaries).</li>
41+
<li><em>A field of a class:</em> <code>package.Class#fieldName</code></li>
42+
<li><em>A method signature:</em> It consists of a binary class name, followed by <code>#</code>
43+
and a method name including method parameters: <code>java.lang.String#concat(java.lang.String)</code>
44+
&ndash; All method parameters need to use fully qualified class names!</li>
45+
</ul>
46+
47+
<p>The error message displayed when the signature matches can be given at the end of each
48+
signature line using &quot;<code>@</code>&quot; as separator:</p>
49+
50+
<pre>
51+
java.lang.String @ You are crazy that you disallow strings
52+
</pre>
53+
54+
<p>To not repeat the same message after each signature, you can prepend signatures
55+
with a default message. Use a line starting with &quot;<code>@defaultMessage</code>&quot;.
56+
57+
<pre>
58+
@defaultMessage You are crazy that you disallow substrings
59+
java.lang.String#substring(int)
60+
java.lang.String#substring(int,int)
61+
</pre>
62+
63+
</body>
64+
</html>

0 commit comments

Comments
 (0)