Commit Graph

3 Commits

Author SHA1 Message Date
Abhinav Gupta 0bff0b8716 sdk/go: Remove 'nolint' directives from package docs
Go treats comments that match the following regex as directives.

    //[a-z0-9]+:[a-z0-9]

Comments that are directives don't show in an entity's documentation.
5a550b6951 (diff-f56160fd9fcea272966a8a1d692ad9f49206fdd8dbcbfe384865a98cd9bc2749R165)

Our code has `//nolint` directives that now show in the API Reference.
This is because these directives are in one of the following forms,
which don't get this special treatment.

    // nolint:foo
    //nolint: foo

This change fixes all such directives found by the regex:
`// nolint|//nolint: `.
See bottom of commit for command used for the fix.

Verification:
Here's the output of `go doc` on some entities
before and after this change.

Before
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi | head -n8
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

nolint: lll, interfacer

nolint: lll, interfacer

const EnvOrganization = "PULUMI_ORGANIZATION" ...
var ErrPlugins = errors.New("pulumi: plugins requested")
```

After
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi | head -n8
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

const EnvOrganization = "PULUMI_ORGANIZATION" ...
var ErrPlugins = errors.New("pulumi: plugins requested")
func BoolRef(v bool) *bool
func Float64Ref(v float64) *float64
func IntRef(v int) *int
func IsSecret(o Output) bool
```

Before
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi URN_
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

func URN_(o string) ResourceOption
    URN_ is an optional URN of a previously-registered resource of this type to
    read from the engine. nolint: revive
```

After:
```
% go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi URN_
package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi"

func URN_(o string) ResourceOption
    URN_ is an optional URN of a previously-registered resource of this type to
    read from the engine.
```

Note that golangci-lint offers a 'nolintlint'  linter
that finds such miuses of nolint,
but it also finds other issues so I've deferred that to a follow up PR.

Resolves 

Related: https://github.com/golangci/golangci-lint/issues/892

[git-generate]
FILES=$(mktemp)
rg -l '// nolint|//nolint: ' |
  tee "$FILES" |
  xargs perl -p -i -e '
    s|// nolint|//nolint|g;
    s|//nolint: |//nolint:|g;
  '
rg '.go$' < "$FILES" | xargs gofmt -w -s
2023-01-06 09:06:47 -08:00
Anton Tayanovskyy e8f6b16c0b Fix unit tests 2022-09-28 10:47:42 -04:00
Anton Tayanovskyy 9597386a89
[codegen/node] Implement support for lazy-loaded Node modules ()
* First experiment: export a type directly, but still use require.

* WIP: Add lazy-loading to utils, build export list.

* Untested: add submodule export generation with lazy-loading

* WIP: Syntactically valid submodule export

* Add tests, finish submodExportList generation

* Clean up comments

* Fix compilation error

* WIP

* Lazy-load class modules and re-export them

* Revert original approach

* Handle the class-with-method case eagerly

* Accept codegen

* Fix typo in method namespace condition

* Fix lazyLoadProperty to call require() in source context

* Support lazy-loading function modules

* Revert useles diff, PR feedback

* Remove extra ws diff

* Remove unused

* Accept codegen output

* Function-only files still need utilites import

* Optimize for not loading enums all the time

* Improve further

* Accept codegen

* Implement flags to control lazy-loading

* Accept codegen tests

* Illustrate on azure-native-nested-types

* Test lazy-loaded functions on output-funcs

* Start factoring out

* More cases

* More unit tests

* Reduce flag surface

* Separate fileInfo structs into its own module

* Merge lazyloads

* Accept codegen changes

* CHANGELOG

* Lint

* Revert caching require()

* Accept codegen

Co-authored-by: Robbie McKinstry <robbiemckinstry@Robbies-MacBook-Pro.local>
Co-authored-by: Robbie McKinstry <robbiemckinstry@macbook-pro.mynetworksettings.com>
2022-09-01 18:42:44 -04:00