Skip to content

Commit a942d57

Browse files
davidbenBoringssl LUCI CQ
authored andcommitted
Support lists and code blocks in doc.go
Our documentation comments already include examples of code blocks and lists, they just don't get rendered right. We also have things that were trying to be lists but aren't. Go ahead and add support for it, and fix the handful of list-like things that didn't get rendered as lists. I took inspiration from CommonMark (https://spec.commonmark.org/0.30/) to resolve questions such as whether blank lines are needed between lists, etc., but this does not support any kind of nesting and is still far from a CommonMark parser. Aligning with CommonMark leaves the door open to pulling in a real Markdown parser if we start to need too many features. I've also borrowed the "block" terminology from CommonMark. One ambiguity of note: whether lists may interrupt paragraphs (i.e. without a blank line in between) is a little thorny. If we say no, this doesn't work: Callers should heed the following warnings: 1) Don't use the function 2) Seriously, don't use this function 3) This function is a bad idea But if we say yes, this renders wrong: This function parses an X.509 certificate (see RFC 5280) into an X509 object. We have examples of both in existing comments, though we could easily add a blank line in the former or rewrap the latter. CommonMark has a discussion on this in https://spec.commonmark.org/0.30/#lists CommonMark says yes, but with a hack that only lists starting with 1 can interrupt paragraphs. Since we're unlikely to cite RFC 1, I've matched for now, but we may want to revisit this if it gets to be a pain. I could imagine this becoming a problem: This function, on success, does some stuff and returns 1. Otherwise, it returns 0. But that looks a little weird and we usually spell out "one" and "zero". I printed all the lists we detected in existing comments, and this has not happened so far. I've also required fewer spaces than CommonMark to trigger a code block. CommonMark uses four, but four spaces plus a leading "//" and a " " is quite a lot. For now I'm not stripping the spaces after the comment marker at comment extraction time and then requiring three spaces, so two spaces relative to normal text. This is mostly to match what we've currently been doing, but we can always change it and our comments later. Change-Id: Ic61a8e93491ed96aba755aec2a5f32914bdc42ae Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/64930 Reviewed-by: Bob Beck <[email protected]> Commit-Queue: David Benjamin <[email protected]>
1 parent 3599db2 commit a942d57

File tree

6 files changed

+249
-93
lines changed

6 files changed

+249
-93
lines changed

include/openssl/bn.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,11 @@ OPENSSL_EXPORT int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
666666
// The callback receives the address of that |BN_GENCB| structure as its last
667667
// argument and the user is free to put an arbitrary pointer in |arg|. The other
668668
// arguments are set as follows:
669-
// event=BN_GENCB_GENERATED, n=i: after generating the i'th possible prime
669+
// - event=BN_GENCB_GENERATED, n=i: after generating the i'th possible prime
670670
// number.
671-
// event=BN_GENCB_PRIME_TEST, n=-1: when finished trial division primality
671+
// - event=BN_GENCB_PRIME_TEST, n=-1: when finished trial division primality
672672
// checks.
673-
// event=BN_GENCB_PRIME_TEST, n=i: when the i'th primality test has finished.
673+
// - event=BN_GENCB_PRIME_TEST, n=i: when the i'th primality test has finished.
674674
//
675675
// The callback can return zero to abort the generation progress or one to
676676
// allow it to continue.

include/openssl/curve25519.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ OPENSSL_EXPORT int SPAKE2_generate_msg(SPAKE2_CTX *ctx, uint8_t *out,
161161
// |*out_key_len| to the number of bytes written.
162162
//
163163
// The resulting keying material is suitable for:
164-
// a) Using directly in a key-confirmation step: i.e. each side could
164+
// - Using directly in a key-confirmation step: i.e. each side could
165165
// transmit a hash of their role, a channel-binding value and the key
166166
// material to prove to the other side that they know the shared key.
167-
// b) Using as input keying material to HKDF to generate a variety of subkeys
167+
// - Using as input keying material to HKDF to generate a variety of subkeys
168168
// for encryption etc.
169169
//
170170
// If |max_out_key_key| is smaller than the amount of key material generated

include/openssl/ec.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ OPENSSL_EXPORT const EC_GROUP *EC_group_p521(void);
121121
// calling |EC_GROUP_free| is optional.
122122
//
123123
// The supported NIDs are:
124-
// NID_secp224r1 (P-224),
125-
// NID_X9_62_prime256v1 (P-256),
126-
// NID_secp384r1 (P-384),
127-
// NID_secp521r1 (P-521)
124+
// - |NID_secp224r1| (P-224)
125+
// - |NID_X9_62_prime256v1| (P-256)
126+
// - |NID_secp384r1| (P-384)
127+
// - |NID_secp521r1| (P-521)
128128
//
129129
// Calling this function causes all four curves to be linked into the binary.
130130
// Prefer calling |EC_group_*| to allow the static linker to drop unused curves.

include/openssl/ssl.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,19 +1461,19 @@ OPENSSL_EXPORT size_t SSL_get_all_standard_cipher_names(const char **out,
14611461
//
14621462
// Available opcodes are:
14631463
//
1464-
// The empty opcode enables and appends all matching disabled ciphers to the
1464+
// - The empty opcode enables and appends all matching disabled ciphers to the
14651465
// end of the enabled list. The newly appended ciphers are ordered relative to
14661466
// each other matching their order in the disabled list.
14671467
//
1468-
// |-| disables all matching enabled ciphers and prepends them to the disabled
1468+
// - |-| disables all matching enabled ciphers and prepends them to the disabled
14691469
// list, with relative order from the enabled list preserved. This means the
14701470
// most recently disabled ciphers get highest preference relative to other
14711471
// disabled ciphers if re-enabled.
14721472
//
1473-
// |+| moves all matching enabled ciphers to the end of the enabled list, with
1473+
// - |+| moves all matching enabled ciphers to the end of the enabled list, with
14741474
// relative order preserved.
14751475
//
1476-
// |!| deletes all matching ciphers, enabled or not, from either list. Deleted
1476+
// - |!| deletes all matching ciphers, enabled or not, from either list. Deleted
14771477
// ciphers will not matched by future operations.
14781478
//
14791479
// A selector may be a specific cipher (using either the standard or OpenSSL
@@ -1483,36 +1483,36 @@ OPENSSL_EXPORT size_t SSL_get_all_standard_cipher_names(const char **out,
14831483
//
14841484
// Available cipher rules are:
14851485
//
1486-
// |ALL| matches all ciphers, except for deprecated ciphers which must be
1486+
// - |ALL| matches all ciphers, except for deprecated ciphers which must be
14871487
// named explicitly.
14881488
//
1489-
// |kRSA|, |kDHE|, |kECDHE|, and |kPSK| match ciphers using plain RSA, DHE,
1489+
// - |kRSA|, |kDHE|, |kECDHE|, and |kPSK| match ciphers using plain RSA, DHE,
14901490
// ECDHE, and plain PSK key exchanges, respectively. Note that ECDHE_PSK is
14911491
// matched by |kECDHE| and not |kPSK|.
14921492
//
1493-
// |aRSA|, |aECDSA|, and |aPSK| match ciphers authenticated by RSA, ECDSA, and
1493+
// - |aRSA|, |aECDSA|, and |aPSK| match ciphers authenticated by RSA, ECDSA, and
14941494
// a pre-shared key, respectively.
14951495
//
1496-
// |RSA|, |DHE|, |ECDHE|, |PSK|, |ECDSA|, and |PSK| are aliases for the
1496+
// - |RSA|, |DHE|, |ECDHE|, |PSK|, |ECDSA|, and |PSK| are aliases for the
14971497
// corresponding |k*| or |a*| cipher rule. |RSA| is an alias for |kRSA|, not
14981498
// |aRSA|.
14991499
//
1500-
// |3DES|, |AES128|, |AES256|, |AES|, |AESGCM|, |CHACHA20| match ciphers
1500+
// - |3DES|, |AES128|, |AES256|, |AES|, |AESGCM|, |CHACHA20| match ciphers
15011501
// whose bulk cipher use the corresponding encryption scheme. Note that
15021502
// |AES|, |AES128|, and |AES256| match both CBC and GCM ciphers.
15031503
//
1504-
// |SHA1|, and its alias |SHA|, match legacy cipher suites using HMAC-SHA1.
1504+
// - |SHA1|, and its alias |SHA|, match legacy cipher suites using HMAC-SHA1.
15051505
//
15061506
// Deprecated cipher rules:
15071507
//
1508-
// |kEDH|, |EDH|, |kEECDH|, and |EECDH| are legacy aliases for |kDHE|, |DHE|,
1508+
// - |kEDH|, |EDH|, |kEECDH|, and |EECDH| are legacy aliases for |kDHE|, |DHE|,
15091509
// |kECDHE|, and |ECDHE|, respectively.
15101510
//
1511-
// |HIGH| is an alias for |ALL|.
1511+
// - |HIGH| is an alias for |ALL|.
15121512
//
1513-
// |FIPS| is an alias for |HIGH|.
1513+
// - |FIPS| is an alias for |HIGH|.
15141514
//
1515-
// |SSLv3| and |TLSv1| match ciphers available in TLS 1.1 or earlier.
1515+
// - |SSLv3| and |TLSv1| match ciphers available in TLS 1.1 or earlier.
15161516
// |TLSv1_2| matches ciphers new in TLS 1.2. This is confusing and should not
15171517
// be used.
15181518
//
@@ -5319,7 +5319,7 @@ enum ssl_compliance_policy_t BORINGSSL_ENUM_INT {
53195319
// doesn't undo other policies it's an error to try and set it.
53205320
ssl_compliance_policy_none,
53215321

5322-
// ssl_policy_fips_202205 configures a TLS connection to use:
5322+
// ssl_compliance_policy_fips_202205 configures a TLS connection to use:
53235323
// * TLS 1.2 or 1.3
53245324
// * For TLS 1.2, only ECDHE_[RSA|ECDSA]_WITH_AES_*_GCM_SHA*.
53255325
// * For TLS 1.3, only AES-GCM

util/doc.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ div.title {
1616
margin-bottom: 2em;
1717
}
1818

19-
ol {
19+
ol.toc {
2020
list-style: none;
21+
padding-left: 0;
2122
margin-bottom: 4em;
2223
}
2324

24-
li a {
25+
ol.toc li a {
2526
color: black;
2627
}
2728

@@ -49,12 +50,16 @@ div.decl p:first-child .first-word {
4950
font-size: 1.5em;
5051
}
5152

52-
.section pre {
53+
pre.code {
5354
background-color: #b2c9db;
5455
padding: 5px;
5556
border-radius: 5px;
5657
}
5758

59+
.comment pre {
60+
margin-left: 2em;
61+
}
62+
5863
td {
5964
padding: 2px;
6065
}

0 commit comments

Comments
 (0)