Skip to content

Commit a0347ec

Browse files
autodoc updates (#1300)
Co-authored-by: lestrrat <lestrrat@users.noreply.github.com>
1 parent 97e0d3b commit a0347ec

File tree

6 files changed

+54
-54
lines changed

6 files changed

+54
-54
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import (
4545
"github.com/lestrrat-go/jwx/v3/jwt"
4646
)
4747

48-
func ExampleJWX() {
48+
func Example() {
4949
// Parse, serialize, slice and dice JWKs!
5050
privkey, err := jwk.ParseKey(jsonRSAPrivateKey)
5151
if err != nil {

docs/01-jwt.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import (
8181
"github.com/lestrrat-go/jwx/v3/jwt"
8282
)
8383

84-
func ExampleJWT_Parse() {
84+
func Example_jwt_parse() {
8585
tok, err := jwt.Parse(jwtSignedWithHS256, jwt.WithKey(jwa.HS256(), jwkSymmetricKey))
8686
if err != nil {
8787
fmt.Printf("%s\n", err)
@@ -112,7 +112,7 @@ import (
112112
"github.com/lestrrat-go/jwx/v3/jwt"
113113
)
114114

115-
func ExampleJWT_ReadFile() {
115+
func Example_jwt_readfile() {
116116
f, err := os.CreateTemp(``, `jwt_readfile-*.jws`)
117117
if err != nil {
118118
fmt.Printf("failed to create temporary file: %s\n", err)
@@ -154,7 +154,7 @@ import (
154154
"github.com/lestrrat-go/jwx/v3/jwt"
155155
)
156156

157-
func ExampleJWT_ParseRequest_Authorization() {
157+
func Example_jwt_parse_request_authorization() {
158158
req, err := http.NewRequest(http.MethodGet, `https://github.com/lestrrat-go/jwx`, nil)
159159
if err != nil {
160160
fmt.Printf("failed to create request: %s\n", err)
@@ -239,7 +239,7 @@ import (
239239
"github.com/lestrrat-go/jwx/v3/jwt"
240240
)
241241

242-
func ExampleJWT_Construct() {
242+
func Example_jwt_construct() {
243243
tok := jwt.New()
244244
if err := tok.Set(jwt.IssuerKey, `github.com/lestrrat-go/jwx`); err != nil {
245245
fmt.Printf("failed to set claim: %s\n", err)
@@ -284,7 +284,7 @@ import (
284284
"github.com/lestrrat-go/jwx/v3/jwt"
285285
)
286286

287-
func ExampleJWT_Builder() {
287+
func Example_jwt_builder() {
288288
tok, err := jwt.NewBuilder().
289289
Claim(`claim1`, `value1`).
290290
Claim(`claim2`, `value2`).
@@ -324,7 +324,7 @@ import (
324324
"github.com/lestrrat-go/jwx/v3/jwt"
325325
)
326326

327-
func ExampleJWT_ParseWithKey() {
327+
func Example_jwt_parse_with_key() {
328328
const keysrc = `{"kty":"oct","k":"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow"}`
329329

330330
key, err := jwk.ParseKey([]byte(keysrc))
@@ -369,7 +369,7 @@ import (
369369
"github.com/lestrrat-go/jwx/v3/jwt"
370370
)
371371

372-
func ExampleJWT_ParseWithKeySet() {
372+
func Example_jwt_parse_with_key_set() {
373373
var serialized []byte
374374
var signingKey jwk.Key
375375
var keyset jwk.Set
@@ -512,7 +512,7 @@ import (
512512
"github.com/lestrrat-go/jwx/v3/jwt"
513513
)
514514

515-
func ExampleJWT_ParseWithKeyProvider_UseToken() {
515+
func Example_jwt_parse_with_key_provider_use_token() {
516516
// This example shows how one might use the information in the JWT to
517517
// load different keys.
518518

@@ -586,7 +586,7 @@ func ExampleJWT_ParseWithKeyProvider_UseToken() {
586586
//
587587
}
588588

589-
func ExampleJWT_ParseWithKeyProvider() {
589+
func Example_jwt_parse_with_key_provider() {
590590
// Pretend that this is a storage somewhere (maybe a database) that maps
591591
// a signature algorithm to a key
592592
store := make(map[jwa.KeyAlgorithm]interface{})
@@ -674,7 +674,7 @@ import (
674674
"github.com/lestrrat-go/jwx/v3/jwt"
675675
)
676676

677-
func ExampleJWT_ParseWithJKU() {
677+
func Example_jwt_parse_with_jku() {
678678
set := jwk.NewSet()
679679

680680
var signingKey jwk.Key
@@ -761,7 +761,7 @@ import (
761761
"github.com/lestrrat-go/jwx/v3/jwt"
762762
)
763763

764-
func ExampleJWT_Validate() {
764+
func Example_jwt_validate() {
765765
tok, err := jwt.NewBuilder().
766766
Issuer(`github.com/lestrrat-go/jwx`).
767767
Expiration(time.Now().Add(-1 * time.Hour)).
@@ -821,7 +821,7 @@ import (
821821
"github.com/lestrrat-go/jwx/v3/jwt"
822822
)
823823

824-
func ExampleJWT_ValidateIssuer() {
824+
func Example_jwt_validate_issuer() {
825825
tok, err := jwt.NewBuilder().
826826
Issuer(`github.com/lestrrat-go/jwx`).
827827
Expiration(time.Now().Add(time.Hour)).
@@ -861,7 +861,7 @@ import (
861861
"github.com/lestrrat-go/jwx/v3/jwt"
862862
)
863863

864-
func ExampleJWT_ValidateValidator() {
864+
func Example_jwt_validate_validator() {
865865
validator := jwt.ValidatorFunc(func(_ context.Context, t jwt.Token) error {
866866
iat, ok := t.IssuedAt()
867867
if !ok {
@@ -912,7 +912,7 @@ import (
912912
"github.com/lestrrat-go/jwx/v3/jwt"
913913
)
914914

915-
func ExampleJWT_ValidateDetectErrorType() {
915+
func Example_jwt_validate_detect_error_type() {
916916
tok, err := jwt.NewBuilder().
917917
Issuer(`github.com/lestrrat-go/jwx`).
918918
Expiration(time.Now().Add(-1 * time.Hour)).
@@ -994,7 +994,7 @@ import (
994994
"github.com/lestrrat-go/jwx/v3/jwt"
995995
)
996996

997-
func ExampleJWT_SerializeJSON() {
997+
func Example_jwt_serialize_json() {
998998
tok, err := jwt.NewBuilder().
999999
Issuer(`github.com/lestrrat-go/jwx`).
10001000
IssuedAt(time.Unix(aLongLongTimeAgo, 0)).
@@ -1031,7 +1031,7 @@ import (
10311031
"github.com/lestrrat-go/jwx/v3/jwt"
10321032
)
10331033

1034-
func ExampleJWT_SerializeJWS() {
1034+
func Example_jwt_serialize_jws() {
10351035
tok, err := jwt.NewBuilder().
10361036
Issuer(`github.com/lestrrat-go/jwx`).
10371037
IssuedAt(time.Unix(aLongLongTimeAgo, 0)).
@@ -1097,7 +1097,7 @@ import (
10971097
"github.com/lestrrat-go/jwx/v3/jwt"
10981098
)
10991099

1100-
func ExampleJWT_SerializeJWEJWS() {
1100+
func Example_jwt_serialize_jwe_jws() {
11011101
tok, err := jwt.NewBuilder().
11021102
Issuer(`github.com/lestrrat-go/jwx`).
11031103
IssuedAt(time.Unix(aLongLongTimeAgo, 0)).
@@ -1176,7 +1176,7 @@ import (
11761176
"github.com/lestrrat-go/jwx/v3/jwt"
11771177
)
11781178

1179-
func ExampleJWT_FlattenAudience() {
1179+
func Example_jwt_flatten_Audience() {
11801180
// Sometimes you need to "flatten" the "aud" claim because of
11811181
// parsers developed by people who apparently didn't read the RFC.
11821182
//
@@ -1274,7 +1274,7 @@ import (
12741274
"github.com/lestrrat-go/jwx/v3/jwt"
12751275
)
12761276

1277-
func ExampleJWTPlainStruct() {
1277+
func Example_jwt_plain_struct() {
12781278
t1, err := jwt.NewBuilder().
12791279
Issuer("https://github.com/lestrrat-go/jwx/v3/examples").
12801280
Subject("raw_struct").

docs/02-jws.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import (
4747
"github.com/lestrrat-go/jwx/v3/jws"
4848
)
4949

50-
func ExampleJWS_Parse() {
50+
func Example_jws_parse() {
5151
const src = `eyJhbGciOiJIUzI1NiJ9.TG9yZW0gaXBzdW0.idbECxA8ZhQbU0ddZmzdRZxQmHjwvw77lT2bwqGgNMo`
5252

5353
msg, err := jws.Parse([]byte(src))
@@ -80,7 +80,7 @@ import (
8080
"github.com/lestrrat-go/jwx/v3/jws"
8181
)
8282

83-
func ExampleJWS_ReadFile() {
83+
func Example_jws_readfile() {
8484
const src = `eyJhbGciOiJIUzI1NiJ9.TG9yZW0gaXBzdW0.idbECxA8ZhQbU0ddZmzdRZxQmHjwvw77lT2bwqGgNMo`
8585
f, err := os.CreateTemp(``, `jws_readfile-*.jws`)
8686
if err != nil {
@@ -128,7 +128,7 @@ import (
128128
"github.com/lestrrat-go/jwx/v3/jwt"
129129
)
130130

131-
func ExampleJWS_UseJWSHeader() {
131+
func Example_jws_use_jws_header() {
132132
key, err := jwk.Import([]byte(`abracadabra`))
133133
if err != nil {
134134
fmt.Printf(`failed to create new symmetric key: %s`, err)
@@ -193,7 +193,7 @@ import (
193193
"github.com/lestrrat-go/jwx/v3/jws"
194194
)
195195

196-
func ExampleJWS_Sign() {
196+
func Example_jws_sign() {
197197
key, err := jwk.Import([]byte(`abracadabra`))
198198
if err != nil {
199199
fmt.Printf("failed to create key: %s\n", err)
@@ -231,7 +231,7 @@ import (
231231
"github.com/lestrrat-go/jwx/v3/jws"
232232
)
233233

234-
func ExampleJWS_SignJSON() {
234+
func Example_jws_sign_json() {
235235
var keys []jwk.Key
236236

237237
for i := 0; i < 3; i++ {
@@ -278,7 +278,7 @@ import (
278278
"github.com/lestrrat-go/jwx/v3/jws"
279279
)
280280

281-
func ExampleJWS_SignDetachedPayload() {
281+
func Example_jws_sign_detached_payload() {
282282
payload := `$.02`
283283

284284
key, err := jwk.Import([]byte(`abracadabra`))
@@ -321,7 +321,7 @@ import (
321321
"github.com/lestrrat-go/jwx/v3/jws"
322322
)
323323

324-
func ExampleJWS_SignWithHeaders() {
324+
func Example_jws_sign_with_headers() {
325325
key, err := jwk.Import([]byte(`abracadabra`))
326326
if err != nil {
327327
fmt.Printf("failed to create key: %s\n", err)
@@ -371,7 +371,7 @@ import (
371371
"github.com/lestrrat-go/jwx/v3/jws"
372372
)
373373

374-
func ExampleJWS_VerifyWithKey() {
374+
func Example_jws_verify_with_key() {
375375
const src = `eyJhbGciOiJIUzI1NiJ9.TG9yZW0gaXBzdW0.EjVtju0uXjSz6QevNgAqN1ESd9aNCP7-tJLifkQ0_C0`
376376

377377
key, err := jwk.Import([]byte(`abracadabra`))
@@ -417,7 +417,7 @@ import (
417417
"github.com/lestrrat-go/jwx/v3/jws"
418418
)
419419

420-
func ExampleJWS_VerifyWithJWKSet() {
420+
func Example_jws_verify_with_jwk_set() {
421421
// Setup payload first...
422422
privkey, err := rsa.GenerateKey(rand.Reader, 2048)
423423
if err != nil {
@@ -473,7 +473,7 @@ import (
473473
"github.com/lestrrat-go/jwx/v3/jws"
474474
)
475475

476-
func ExampleJWS_VerifyDetachedPayload() {
476+
func Example_jws_verify_detached_payload() {
477477
serialized := `eyJhbGciOiJIUzI1NiJ9..H14oXKwyvAsl0IbBLjw9tLxNIoYisuIyb_oDV4-30Vk`
478478
payload := `$.02`
479479

@@ -593,7 +593,7 @@ func (s CirclEdDSASignerVerifier) Verify(payload []byte, signature []byte, keyif
593593
}
594594
}
595595

596-
func ExampleJWS_CustomSignerVerifier() {
596+
func Example_jws_custom_signer_verifier() {
597597
// This example shows how to register external jws.Signer / jws.Verifier for
598598
// a given algorithm.
599599
jws.RegisterSigner(jwa.EdDSA(), jws.SignerFactoryFn(NewCirclEdDSASigner))

docs/03-jwe.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"github.com/lestrrat-go/jwx/v3/jwe"
3636
)
3737

38-
func ExampleJWE_Parse() {
38+
func Example_jwe_parse() {
3939
const src = `eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.KrFTaMKVY_iUKYYk905QjbUf_fpBXvXCzIAfbPoPMGViDzxtgz5qnch8waV7wraVDfzpW7JfPOw6Nz_-XRwN3Vbud48bRYFw92GkC0M6kpKFpl_xgZxGN47ggNk9hzgqd7mFCuyufeYdn5c2fPoRZAV4UxvakLozEYcQo-eZaFmoYS4pyoC-IKKRikobW8n__LksMzXc_Vps1axn5kdpxsKQ4k1oayvUrgWX2PMxKn_TcLEKHtCN7qRlJ5hkKbZAXAdd34zGWcFV5gc1tcLs6HFhnebo8GUgItTYWBKSKzF6MyLJNRSUPFVq9q-Jxi1juXIlDrv_7rHVsdokQmBfvA.bK7z7Z3gEzFDgDQvNen0Ww.2hngnAVrmucUpJKLgIzYcg.CHs3ZP7JtG430Dl9YAKLMAl`
4040

4141
msg, err := jwe.Parse([]byte(src))
@@ -68,7 +68,7 @@ import (
6868
"github.com/lestrrat-go/jwx/v3/jwe"
6969
)
7070

71-
func ExampleJWE_ReadFile() {
71+
func Example_jwe_readfile() {
7272
const src = `eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.KrFTaMKVY_iUKYYk905QjbUf_fpBXvXCzIAfbPoPMGViDzxtgz5qnch8waV7wraVDfzpW7JfPOw6Nz_-XRwN3Vbud48bRYFw92GkC0M6kpKFpl_xgZxGN47ggNk9hzgqd7mFCuyufeYdn5c2fPoRZAV4UxvakLozEYcQo-eZaFmoYS4pyoC-IKKRikobW8n__LksMzXc_Vps1axn5kdpxsKQ4k1oayvUrgWX2PMxKn_TcLEKHtCN7qRlJ5hkKbZAXAdd34zGWcFV5gc1tcLs6HFhnebo8GUgItTYWBKSKzF6MyLJNRSUPFVq9q-Jxi1juXIlDrv_7rHVsdokQmBfvA.bK7z7Z3gEzFDgDQvNen0Ww.2hngnAVrmucUpJKLgIzYcg.CHs3ZP7JtG430Dl9YAKLMAl`
7373

7474
f, err := os.CreateTemp(``, `jwe_readfile_example-*.jwe`)
@@ -118,7 +118,7 @@ import (
118118
"github.com/lestrrat-go/jwx/v3/jwk"
119119
)
120120

121-
func ExampleJWE_Encrypt() {
121+
func Example_jwe_encrypt() {
122122
rawprivkey, err := rsa.GenerateKey(rand.Reader, 2048)
123123
if err != nil {
124124
fmt.Printf("failed to create raw private key: %s\n", err)
@@ -176,7 +176,7 @@ import (
176176
"github.com/lestrrat-go/jwx/v3/jwk"
177177
)
178178

179-
func ExampleJWE_EncryptJSON() {
179+
func Example_jwe_encrypt_json() {
180180
rawprivkey, err := rsa.GenerateKey(rand.Reader, 2048)
181181
if err != nil {
182182
fmt.Printf("failed to create raw private key: %s\n", err)
@@ -211,7 +211,7 @@ func ExampleJWE_EncryptJSON() {
211211
// Lorem ipsum
212212
}
213213

214-
func ExampleJWE_EncryptJSONMulti() {
214+
func Example_jwe_encrypt_json_multi() {
215215
var privkeys []jwk.Key
216216
var pubkeys []jwk.Key
217217

@@ -289,7 +289,7 @@ import (
289289
"github.com/lestrrat-go/jwx/v3/jwe"
290290
)
291291

292-
func ExampleJWE_SignWithHeaders() {
292+
func Example_jwe_sign_with_headers() {
293293
privkey, err := rsa.GenerateKey(rand.Reader, 2048)
294294
if err != nil {
295295
fmt.Printf("failed to create private key: %s\n", err)
@@ -350,7 +350,7 @@ import (
350350
"github.com/lestrrat-go/jwx/v3/jwe"
351351
)
352352

353-
func ExampleJWE_VerifyWithKey() {
353+
func Example_jwe_verify_with_key() {
354354
const payload = "Lorem ipsum"
355355
encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSA_OAEP(), jwkRSAPublicKey))
356356
if err != nil {
@@ -396,7 +396,7 @@ import (
396396
"github.com/lestrrat-go/jwx/v3/jwk"
397397
)
398398

399-
func ExampleJWE_VerifyWithJWKSet() {
399+
func Example_jwe_verify_with_jwk_set() {
400400
privkey, err := rsa.GenerateKey(rand.Reader, 2048)
401401
if err != nil {
402402
fmt.Printf("failed to create private key: %s\n", err)

0 commit comments

Comments
 (0)