Skip to content

docs: add comprehensive godoc comments to core API#28

Merged
AWaterColorPen merged 1 commit intomainfrom
feature/phase1-godoc-comments
Apr 14, 2026
Merged

docs: add comprehensive godoc comments to core API#28
AWaterColorPen merged 1 commit intomainfrom
feature/phase1-godoc-comments

Conversation

@AWaterColorPen
Copy link
Copy Markdown
Owner

Summary

This PR adds comprehensive godoc comments to the core API files as part of Phase 1 – Foundation Modernization (Task 1.3 in the modernization plan).

Changes

  • doc.go (new): Package-level overview with key concepts, quick-start example, and architecture overview
  • schema.go: User, Role, Object, Domain, Policy, Directory, DirectoryRequest/Response and all related types
  • metadata.go: MetaDB interface and all method signatures with parameter/return docs
  • constant.go: All exported constants (ObjectPType, Read/Write/Manage, DirectorySearchAll/Top, UpsertType*)
  • error.go: All sentinel errors with context on when each is returned and errors.Is usage example
  • options.go: Options, Option functional type, DefaultSuperadmin* vars
  • register.go: Factory, Register[U,R,O,D], DefaultFactory and unexported helpers
  • inheritance.go: InheritanceEdge, EdgeSorter, InheritanceGraph and all methods
  • casbin.go: IEnforcer (all 28 method docs), SetWatcher, WatcherOption, NewEnforcer
  • schema_buildin.go: NamedObject, SampleSuperadminRole/Domain, GetSuperadmin*
  • dictionary.go: IDictionary, IFeatureDictionary, ICreatorDictionary
  • metadata_database.go: DBOption and its NewDB method

Testing

All existing tests pass (go test ./...).

Part of

Phase 1 – Foundation Modernization, Task 1.3: Enrich godoc on core public API

Add a new doc.go package-level overview and enrich all core files with
godoc comments:

- doc.go: package overview with key concepts and quick-start example
- schema.go: User, Role, Object, Domain, Policy, Directory, and related types
- metadata.go: MetaDB, UpsertType interface and all method docs
- constant.go: all constants (ObjectPType, actions, directory search types, etc.)
- error.go: all sentinel errors with usage guidance
- options.go: Options, Option, DefaultSuperadmin* vars
- register.go: Factory, Register, DefaultFactory and helper funcs
- inheritance.go: InheritanceEdge, EdgeSorter, InheritanceGraph and methods
- casbin.go: IEnforcer (all methods), SetWatcher, WatcherOption, NewEnforcer
- schema_buildin.go: NamedObject, SampleSuperadminRole/Domain, GetSuperadmin*
- dictionary.go: IDictionary, IFeatureDictionary, ICreatorDictionary
- metadata_database.go: DBOption

All existing tests pass (go test ./...).
@AWaterColorPen AWaterColorPen merged commit 12c37ba into main Apr 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant