@@ -51,6 +51,7 @@ import (
51
51
"golang.org/x/tools/gopls/internal/util/safetoken"
52
52
"golang.org/x/tools/gopls/internal/util/slices"
53
53
"golang.org/x/tools/gopls/internal/util/typesutil"
54
+ "golang.org/x/tools/internal/stdlib"
54
55
"golang.org/x/tools/internal/typesinternal"
55
56
)
56
57
@@ -415,6 +416,12 @@ header {
415
416
padding: 0.3em;
416
417
}
417
418
419
+ .Documentation-sinceVersion {
420
+ font-weight: normal;
421
+ color: #808080;
422
+ float: right;
423
+ }
424
+
418
425
#pkgsite { height: 1.5em; }
419
426
420
427
#hdr-Selector {
@@ -782,15 +789,25 @@ window.addEventListener('load', function() {
782
789
values (docpkg .Vars )
783
790
}
784
791
792
+ // addedInHTML returns an HTML division containing the Go release version at
793
+ // which this obj became available.
794
+ addedInHTML := func (obj types.Object ) string {
795
+ if sym := StdSymbolOf (obj ); sym != nil && sym .Version != stdlib .Version (0 ) {
796
+ return fmt .Sprintf ("<span class='Documentation-sinceVersion'>added in %v</span>" , sym .Version )
797
+ }
798
+ return ""
799
+ }
800
+
785
801
// package-level functions
786
802
fmt .Fprintf (& buf , "<h2 id='hdr-Functions'>Functions</h2>\n " )
787
803
// funcs emits a list of package-level functions,
788
804
// possibly organized beneath the type they construct.
789
805
funcs := func (funcs []* doc.Func ) {
790
806
for _ , docfn := range funcs {
791
807
obj := scope .Lookup (docfn .Name ).(* types.Func )
792
- fmt .Fprintf (& buf , "<h3 id='%s'>func %s</h3>\n " ,
793
- docfn .Name , objHTML (pkg .FileSet (), web , obj ))
808
+
809
+ fmt .Fprintf (& buf , "<h3 id='%s'>func %s %s</h3>\n " ,
810
+ docfn .Name , objHTML (pkg .FileSet (), web , obj ), addedInHTML (obj ))
794
811
795
812
// decl: func F(params) results
796
813
fmt .Fprintf (& buf , "<pre class='code'>%s</pre>\n " ,
@@ -808,8 +825,8 @@ window.addEventListener('load', function() {
808
825
tname := scope .Lookup (doctype .Name ).(* types.TypeName )
809
826
810
827
// title and source link
811
- fmt .Fprintf (& buf , "<h3 id='%s'>type %s</a> </h3>\n " ,
812
- doctype .Name , objHTML (pkg .FileSet (), web , tname ))
828
+ fmt .Fprintf (& buf , "<h3 id='%s'>type %s %s </h3>\n " ,
829
+ doctype .Name , objHTML (pkg .FileSet (), web , tname ), addedInHTML ( tname ) )
813
830
814
831
// declaration
815
832
// TODO(adonovan): excise non-exported struct fields somehow.
@@ -828,10 +845,10 @@ window.addEventListener('load', function() {
828
845
// methods on T
829
846
for _ , docmethod := range doctype .Methods {
830
847
method , _ , _ := types .LookupFieldOrMethod (tname .Type (), true , tname .Pkg (), docmethod .Name )
831
- fmt .Fprintf (& buf , "<h4 id='%s.%s'>func (%s) %s</h4>\n " ,
848
+ fmt .Fprintf (& buf , "<h4 id='%s.%s'>func (%s) %s %s </h4>\n " ,
832
849
doctype .Name , docmethod .Name ,
833
850
docmethod .Orig , // T or *T
834
- objHTML (pkg .FileSet (), web , method ))
851
+ objHTML (pkg .FileSet (), web , method ), addedInHTML ( method ) )
835
852
836
853
// decl: func (x T) M(params) results
837
854
fmt .Fprintf (& buf , "<pre class='code'>%s</pre>\n " ,
0 commit comments