Update automated documentation tool.

Add the ability to include notes, and add a note to ChaCha20
specifying the exact ChaCha variant that's included.

Prefer the existing name over the name coming from the device,
allowing us to customize names by updating them in the JSON file.  Use
AES/GCM/NoPadding over AES/GCM/NOPADDING to match other ciphers.

Wrap a number of fields with white-space:nowrap, so that algorithm
names and other identifiers aren't awkwardly broken in the middle,
like in OAEPwithSHA-1andMGF1Padding.

Add the ability to only output a single category, to more easily allow
updating Javadoc for a single class.

Bug: 70936054
Test: update_crypto_support_test.py
Change-Id: I4b2bb59adca7b003e357776783ee723bdf82302c
diff --git a/tools/docs/crypto/update_crypto_support.py b/tools/docs/crypto/update_crypto_support.py
index 3138d7d..83c4ec8 100755
--- a/tools/docs/crypto/update_crypto_support.py
+++ b/tools/docs/crypto/update_crypto_support.py
@@ -195,10 +195,10 @@
         alg_union = set(prev_algorithms) | set(current_category)
         for alg in alg_union:
             prev_alg = find_by_normalized_name(prev_category['algorithms'], alg)
-            if alg in name_dict:
-                new_algorithm = {'name': name_dict[alg]}
-            elif prev_alg is not None:
+            if prev_alg is not None:
                 new_algorithm = {'name': prev_alg['name']}
+            elif alg in name_dict:
+                new_algorithm = {'name': name_dict[alg]}
             else:
                 new_algorithm = {'name': alg}
             if category not in CASE_SENSITIVE_CATEGORIES:
@@ -226,6 +226,8 @@
             else:
                 # Only in the new set, so add it
                 new_level = '%d+' % api_level
+            if alg in prev_algorithms and 'note' in prev_alg:
+                new_algorithm['note'] = prev_alg['note']
             new_algorithm['supported_api_levels'] = new_level
             new_category['algorithms'].append(new_algorithm)
         if new_category['algorithms']: