• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2layout: default
3title: APIs & Docs
4parent: Release & Milestone Tasks
5grand_parent: Contributors
6nav_order: 20
7---
8
9<!--
10© 2021 and later: Unicode, Inc. and others.
11License & terms of use: http://www.unicode.org/copyright.html
12-->
13
14# APIs & Docs
15{: .no_toc }
16
17## Contents
18{: .no_toc .text-delta }
19
201. TOC
21{:toc}
22
23---
24
25## Update API status comments
26
27### ICU4C
28
291.  **Note: for ICU4C 49m2 or later, will require Doxygen 1.7.5.1 or later (
30    see** [ICU-8862](https://unicode-org.atlassian.net/browse/ICU-8862) **).**
31    On Linux with debian style package management,
32
33    `sudo apt-get install doxygen`
34
35    Or, to install manually
36    1.  To update Doxygen, first [download binary or source release
37        here](http://doxygen.org/download.html#latestsrc)
38    2.  Unpack the release, and run something like<br>
39        "`configure --prefix /usr/local`" (to install into /usr/local/bin etc)<br>
40        (Note for the binary release, 'configure' just builds an installer.)
41    3.  Run "`make install`" with appropriate permission (perhaps
42        "`sudo make install`".)
43    4.  Verify that '`doxygen --version`' gives the correct number.
44
452.  Update the API documentation in all header files (.h file) to have correct
46    @draft/@stable/@deprecated labels.
473.  Update docmain.h
484.  ./configure
495.  make doc
506.  Follow instructions in
51    [tools/release/java/readme.txt](https://htmlpreview.github.io/?https://github.com/unicode-org/icu/blob/main/tools/release/java/readme.txt)
52    to generate API status change report.
537.  Make sure that ICU headers work with U_HIDE_DRAFT_API and other such
54    switches.
558.  Verify that U_DRAFT and U_STABLE match the @draft and @stable tags (same for
56    other such pairs declaration macro vs. tag).
57    1.  For example, on Linux:
58    2.  grep --recursive --include="\*.h" --exclude-dir=".svn" -e "@deprecated"
59        -A 5 . > at-deprecated.txt
60    3.  grep --recursive --include="\*.h" --exclude-dir=".svn" -e "U_DEPRECATED"
61        -B 5 -A 1 . > u_deprecated.txt
62    4.  Do this for draft, deprecated, obsolete, internal.
63    5.  For @stable, we either verify by cleaning up all others or we need to
64        write a script.
65
66### ICU4J
67
68Update the API documentation to have correct @draft/@stable/@deprecated labels.
69See the [User Guide, ICU Architectural Design, ICU API
70compatibility](https://unicode-org.github.io/icu/userguide/icu/design#icu-api-compatibility).
71
72On ICU4J, run
73[com.ibm.icu.dev.tool.docs.CheckTags](https://github.com/unicode-org/icu/blob/main/icu4j/tools/build/src/com/ibm/icu/dev/tool/docs/CheckTags.java)
74(see file for instructions). This requires a JDK with javadoc available. The
75tool will need to change to reflect the release number to search for.
76
77To check the API status changes, run the ant target "apireport" to generate the
78report since the previous official release.
79
80Make sure **@internal APIs** are also marked as @deprecated:
81
82```
83* @internal
84* @deprecated This API is ICU internal only.
85@Deprecated
86```
87
88---
89
90## Promote draft APIs to stable
91
92APIs previously introduced as @draft are reviewed for every new release. The
93current policy is to keep @draft status at least in one release cycle. For
94example, a new @draft API introduced in ICU 60 will be kept @draft in ICU 61.
95Then the API will be reviewed by ICU technical committee before ICU 62 release
96and the API can be promoted to @stable status.
97
98### **ICU4C**
99
100Andy's method (from email 2019-sep-05):
101
102*   Creation of the promotion spreadsheet was done by hand. It's something of an
103    iterative process.
104*   Start by making a copy of the previous release spread sheet, to get the
105    format, and probable entries for older @draft items that are perpetually
106    being held back.
107*   Do the API promotion - search the sources for @draft, and make a best guess
108    at what to promote. Add entries to the spread sheet as you go. Note any
109    items you're not sure about.
110*   Run the API change report tool, see what looks inconsistent, fix up the
111    sources and rerun as needed. Deleted functions will first show up here, and
112    are added to the spread sheet.
113*   Cross-check the API change report and the spread sheet.
114*   The whole thing takes a bit of time to do.
115
116### **ICU4J**
117
1181.  Create a new GitHub branch.
1192.  Run next ant target: `$ ant draftAPIsTSV`
1203.  This **ant** target generates a tab-separated values file at
121    icu4j/out/draftAPIs.tsv.
1224.  Import the TSV file to Google spread sheet - for example, [ICU4J 61 Draft
123    API
124    Promotion](https://docs.google.com/spreadsheets/d/135RDyY6cWKBBvNuVE9ne8HfsItZu_CvLh47hKjr3UqM/edit#gid=1384666589).
125    *   Create the spreadsheet in the shared ***ICU Projects*** folder.
1265.  Review all APIs introduced in 2 releases ago or older. For example, 59 or
127    older for ICU 61 release.
128    *   Any API added 2 or more releases ago is a candidate for promotion.
129    *   Newer APIs should be left in @draft state.
1306.  Check each API entry has a corresponding approved API proposal. For example,
131    [ICU 59 API proposal
132    status](https://docs.google.com/document/d/12dHTG3e9WXb7C1Xdc2bcXE0BK8f6IoufoUAPcz4ZT2I/edit).
133    Note: An API proposal might have been created before the API proposal doc
134    version, so you may need to look at older version of API proposal status
135    doc.
1367.  Mark APIs proposed for promotion, and add note in the spread sheet.
1378.  Update API comments in ICU4J source code. In this case, @draft is replaced
138    with @stable (do not change ICU version, for example, "@draft ICU 59" will
139    be changed to "@stable ICU 59").
1409.  Run next ant target to generate an API change report html: `$ ant apireport`
14110. Review the report, sent the report file and the link of the spread sheet to
142    ICU technical committee members for review.
14311. Once ICU TC approves the proposed change, create a pull request (PR), wait
144    for review, and merge the branch into the main branch.
145
146---
147
148## Update the API Change Report
149
150### ICU4C
151
152This work is done in the root of icu4c:
153
1541.  Update the API documentation in all header files (.h file) to have correct
155    @draft/@stable/@deprecated/@obsolete labels.
1562.  Update docmain.h with additions or removals as needed.
1573.  `source/configure`
1584.  `make doc`
1595.  Follow instructions in
160    [tools/release/java/readme.txt](https://github.com/unicode-org/icu/blob/main/tools/release/java/readme.txt).
161
162### ICU4J
163
164This work is done in the root of icu4j:
165
1661.  Make sure JAVA_HOME is set to JDK 8. This report creation fails with JDK 11.
167    For example, in Linux:
168    *   `export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64`
1692.  Then run ant task "clean" and "apireport" at <icu4j_root>:
170    *   `ant clean apireport`
1713.  Above will produce API change report file
172    <code><icu4j_root>/<b>out</b>/icu4j_compare_xxx_yyy.html</code>
1734.  Make sure there are any new doc tag errors are reported. (As of ICU 4.4,
174    ArabicShaping constants do not have proper tags - otherwise, clean)
1755.  Copy generated report file to `<icu4j_root>/APIChangeReport.html` and check
176    it in.
177
178Once official release version is shipped, we need to keep API signature
179information file for next iteration. This is not done for milestone releases,
180only after the final official release.
181
1821.  Run ant task "gatherapi" at <icu4j_root>
1832.  Above will produce API signature information file
184    <icu4j_root>/out/icu4jxx.api2.gz
1853.  Copy icu4jxxapi2.gz to <icu4j_root>/tools/build and add it to the repository
186
187---
188
189## Check in API signature data file (ICU4J)
190
191Once APIs are frozen for a reference release, we should check in the API
192signature data file into the repository. The data file will be used for future
193API change report.
194
1951.  Run ant task "gatherapi" at <icu4j_root>
1962.  The output file icu4j<ver>.api3.gz is created in <icu4j_root>/out directory.
1973.  Copy the output .gz file to <icu4j_root>/tools directory and check in the
198    file to the repository.
1994.  You may delete very old versions of the API signature files. Keeping 10
200    versions to the latest should be good enough.
201
202Note: This task is only necessary for reference releases, because we won't
203change public APIs in maintenance releases. The API signature file for an ICU4J
204version is generated and checked into trunk just before ***maint-xx*** branch is
205created for the major version, so we can keep track of API changes in
206maintenance releases of the major version (A maintenance release should have no
207API changes although).
208
209---
210
211## Verify that @draft is surrounded by #ifndef U_HIDE_DRAFT_API etc
212
213In ICU4C, we want every (consecutive group of) `@draft` API to be surrounded by
214`#ifndef U_HIDE_DRAFT_API`. This allows users to `-DU_HIDE_DRAFT_API` to make
215sure they don't use unstable API.
216
217```
218#ifndef U_HIDE_DRAFT_API
219/** @draft ICU 51 */
220U_CAPI u_newFunction1();
221/** @draft ICU 51 */
222U_CAPI u_newFunction2();
223#endif  // U_HIDE_DRAFT_API
224```
225
226Same for `@deprecated` & <code>#ifndef U_HIDE_<b>DEPRECATED</b>_API</code> ..
227`#endif // U_HIDE_DEPRECATED_API`
228
229Same for `@internal` & <code>#ifndef U_HIDE_<b>INTERNAL</b>_API</code> ..
230`#endif // U_HIDE_INTERNAL_API`
231
232Same for `@system` & <code>#ifndef U_HIDE_<b>SYSTEM</b>_API</code> ..
233`#endif // U_HIDE_SYSTEM_API`
234
235Same for `@obsolete` & <code>#ifndef U_HIDE_<b>OBSOLETE</b>_API</code> ..
236`#endif // U_HIDE_OBSOLETE_API`
237
238### Caution
239
240*   We cannot #ifndef-guard virtual methods because that makes the vtable
241    incompatible.
242    *   // Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method
243        since it is virtual.
244*   When you #ifndef-guard enum constants, normally the following unguarded ones
245    (e.g., a _COUNT or _LIMIT) should retain the same numeric values as if the
246    guard was absent.
247
248<span style="background-color:yellow">For more details (and cautions) see the
249Coding Guidelines section [C/C++ Hiding Un-@stable
250APIs](https://unicode-org.github.io/icu/userguide/dev/codingguidelines#cc-hiding-un-stable-apis).</span>
251
252### Task
253
254a) For each of these API status tags, for each API that is tagged with it,
255verify that the API is surrounded by the appropriate #ifndef..#endif.
256
257Note: It is best to not use one single guard for APIs with different ICU
258versions, since they will become stable and thus lose their guards at different
259times. Use one #ifndef..#endif guard per API status and ICU version.
260
261b) For each of these U_HIDE_..._API guards, verify that it only and exactly
262surrounds APIs with the corresponding status tag. In particular, make sure that
263U_HIDE_DRAFT_API does not surround (newly) @stable API.
264
265We don't have tools for this. <span style="background-color:yellow">One approach
266is to</span> use "grep" or similar on the public *common*, *i18n*, *io* header
267files. Use grep options like -A 3, -B 2 and -C 3 for context After, Before, and
268Around the matching line. <span style="background-color:yellow">A better
269approach if you have the tools available is to use a programming-oriented text
270editor that can do (a) powerful regex search across (b) multiple files in
271several specified directories, and (c) display the matched lines in context such
272that (d) they or their context can be edited in place; an example of such a tool
273on macOS is BBEdit. This permits a comprehensive search using an expression such
274as
275"(U_HIDE_\[A-Z_\]+)|(@draft)|(@deprecated)|(@obsolete)|(@system)|(@internal)|(@preview)"
276which permits relatively easy checking for correct enclosure of status tags in
277conditionals.</span>
278
279<span style="background-color:yellow">As part of this, you may need to run side
280searches, for example to verify that no conditionalized type, function or value
281is used by an unconditionalized portion of a header file.</span>
282
283<span style="background-color:yellow">There is no magic bullet; however you
284carry out this step, it will require several hours of going through the
285grep/regex results and manually checking for correct enclosure, checking that
286conditionalized values are not needed elsewhere, etc.</span>
287
288---
289
290## Update udraft.h, usystem.h, uintrnl.h, uobslete.h and udeprctd.h
291
292*Ignore this step for ICU49 and later. In ICU 49 and above, these header files
293and the gendraft/genheaders.pl tool are gone. (Ticket
294[ICU-8571](https://unicode-org.atlassian.net/browse/ICU-8571))*
295
296Instructions ***for ICU4C 4.8.x and earlier***:
297
2981.  make doc
2992.  `cd source/tools/gendraft ; make install-headers`
3003.  Double check the modified files in <icu>/source/common/unicode folder and
301    commit.
302
303---
304
305## Compare ICU4J APIs with JDK
306
307Run the ICU4J versus JDK API comparison tool against the target JDK (anything
308that will come out before our next release, basically) with the tool
309[com.ibm.icu.dev.tool.docs.ICUJDKCompare](https://github.com/unicode-org/icu/blob/main/icu4j/tools/build/src/com/ibm/icu/dev/tool/docs/ICUJDKCompare.java)
310and make sure ICU4J adequately covers the JDK API for the classes we replicate.
311
312---
313
314## Build API documentation
315
316### **ICU4C**
317
318Build the API documentation pages for the new release. Run Doxygen to create the
319javadoc files. Create icu4c-X_X_X-docs.zip
320
321**Note: for ICU4C 49m2 or later, requires Doxygen 1.7.5.1 or later ( see
322[ICU-8862](https://unicode-org.atlassian.net/browse/ICU-8862) )**
323
324#### Create the ICU4C docs zip file:
325
3261.  Go to .../icu4c/source
3272.  Generate the API document pages:<br>
328    `make doc-searchengine`
3293.  The generated API docs are in <path>/icu4c/source/doc/html/<br>
330    `cd <path>/icu4c/source/doc/html/`
3314.  Create a zip file, e.g.,<br>
332    `tar cvfz /tmp/icu4c72rc.tar.gz * # Note: label the file apropriately for the release.
333
334
335#### Create a PR for ICU4C docs using the docs zip file
336
3371.  Follow directions in [How to update ICU docs](https://unicode-org.github.io/icu-docs/HOWTO-Update.html)
338
339    a. First, bring the `main` branch of your icu-docs local copy up to date.
340
341    b. Create and switch to a feature branch based of the latest `main`.  Ex: `git checkout -b ICU-<TICKET-NUMBER>`.
342
343    c. Go to the directory for the version of interest, either
344       `apidoc/dev/icu4c` (release candicate) or `apidoc/released/icu4c`
345       (general release.)
346
347    d. Be sure that you are in the right directory. Then, remove all the files
348        in this directory, e.g., `rm -rf *`. (Remember "git restore" is a good friend!)
349
350    e. Unzip the tar file from above, replacing all documentation. Ex: `tar xvfz /tmp/icu4c72rc.tar.gz`
351
352    e. Remove the zip file if it's in the folder.
353
354    f. `git add .`.  Note that this may remove some old files. That's correct behavior.
355
356    h. `git commit -m "ICU-<TICKET-NUMBER> Update ICU4C API reference docs for
357    XX.Y"`<br>
358    Example: [ICU-21546 Update ICU4C API reference docs for 69.1](https://github.com/unicode-org/icu-docs/pull/25)
359
360    i. `git push origin ICU-<TICKET-NUMBER>`
361
362    j. Create Pull Request from your personal github fork of icu-docs from your newly-pushed branch `ICU-<TICKET-NUMBER>` with a destination of
363    the `unicode-org/icu-docs` repo's `main` branch
364
365    k. Request a review and submit the PR when approved.
366
367Note: This is also referenced below [Upload API documentations](docs.md#upload-api-documentations) for how to make the API docs public.
368
369### ICU4J
370
371**Note:** JCite must be installed for building ICU4J documentation:
372<https://icu.unicode.org/setup/java/ant#TOC-Building-ICU4J-API-Reference-Document-with-JCite>
373
374Build the API documentation pages for the new release:
375
376```
377ant releaseDocs
378```
379
380#### Alternative method:
381
382**Note:** JCite must be installed for building ICU4J documentation:
383<https://icu.unicode.org/setup/java/ant#TOC-Building-ICU4J-API-Reference-Document-with-JCite>
384
385Use the release target
386
387```
388ant releaseVer
389```
390
391which generate all release files.
392
393*   Upload the output files including icu4j-docs.jar to the release page first,
394*   Then update the live API docs from the generated docs.jar.
395
396See [Upload API documentations](docs.md#upload-api-documentations) below for how to make the API docs public.
397
398### Upload API documentations
399
400See <https://unicode-org.github.io/icu-docs/HOWTO-Update.html> for instructions
401to upload to <https://unicode-org.github.io/icu-docs/>
402
403### Update the Readme.html for GA
404
405If there are any last second changes:
406
407*   Make sure to document especially items that affect software that is
408    currently compiled with the previous version of ICU.
409*   Update build/installation instructions as necessary.
410