diff --git a/internal/godocfx/parse.go b/internal/godocfx/parse.go index 0e199518590f..e33439a136af 100644 --- a/internal/godocfx/parse.go +++ b/internal/godocfx/parse.go @@ -619,6 +619,17 @@ func buildTOC(mod string, pis []pkgload.Info, extraFiles []extraFile) tableOfCon func toHTML(p *doc.Package, s string) string { printer := p.Printer() + // Set the DocLinkBaseURL to pkg.go.dev so links to other packages work. + // + // This will send users to pkg.go.dev for other cloud.google.com packages + // that do have docs hosted on cloud.google.com. The link structure for + // docs on cloud.google.com is [prefix]/[module]/[version]/[pkg]. At this + // point, we don't know what the module path is for any given import path. + // So, for simplicity, we're choosing to have working links to pkg.go.dev + // (with occasional links that could be served on cloud.google.com) rather + // than broken links on cloud.google.com. + printer.DocLinkBaseURL = "https://pkg.go.dev" + // Set the default heading level to 2 so we go from H1 to H2. printer.HeadingLevel = 2 diff --git a/internal/godocfx/testdata/golden/index.yml b/internal/godocfx/testdata/golden/index.yml index cc205125726a..c88a0d614320 100644 --- a/internal/godocfx/testdata/golden/index.yml +++ b/internal/godocfx/testdata/golden/index.yml @@ -48,8 +48,9 @@ items: holds arbitrary data as a sequence of bytes, like a file. You\nrefer to objects using a handle, just as with buckets, but unlike buckets\nyou don't explicitly create an object. Instead, the first time you write\nto an object it will be created. - You can use the standard Go io.Reader\nand io.Writer - interfaces to read and write object data:\n
obj := bkt.Object("data")\n//
+    You can use the standard Go io.Reader\nand
+    io.Writer interfaces to read and
+    write object data:\n
obj := bkt.Object("data")\n//
     Write something to obj.\n// w implements io.Writer.\nw := obj.NewWriter(ctx)\n//
     Write some text to obj. This will either create the object or overwrite whatever
     is there already.\nif _, err := fmt.Fprintf(w, "This object contains text.\\n");
@@ -124,16 +125,16 @@ items:
     or\n
  • you are logged into gcloud using application default credentials\nwith impersonation enabled.\n\n

    Detecting GoogleAccessID may not be possible if you are - authenticated using a\ntoken source or using option.WithHTTPClient. + authenticated using a\ntoken source or using option.WithHTTPClient. In this case, you can provide a\nservice account email for GoogleAccessID and the client will attempt to sign\nthe URL or Post Policy using that service account.\n

    To generate the signature, you must have:\n

      \n
    • iam.serviceAccounts.signBlob permissions on the GoogleAccessID service\naccount, and\n
    • the IAM Service Account Credentials API enabled (unless authenticating\nwith a downloaded private key).\n
    \n

    Errors

    \n

    Errors returned by - this client are often of the type googleapi.Error.\nThese - errors can be introspected for more information by using errors.As\nwith - the richer googleapi.Error + this client are often of the type googleapi.Error.\nThese + errors can be introspected for more information by using errors.As\nwith + the richer googleapi.Error type. For example:\n

    var e *googleapi.Error\nif
         ok := errors.As(err, &e); ok {\n\t  if e.Code == 409 { ... }\n}\n
    \n

    Retrying failed requests

    \n

    Methods