Skip to content

Add missing godoc comments to compiler functions#14495

Merged
pelikhan merged 3 commits intomainfrom
copilot/add-godoc-comments-to-compiler-functions
Feb 8, 2026
Merged

Add missing godoc comments to compiler functions#14495
pelikhan merged 3 commits intomainfrom
copilot/add-godoc-comments-to-compiler-functions

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

Several core compiler functions lacked documentation, making discovery via go doc difficult.

Changes

Public API functions (compiler.go):

  • CompileWorkflow() - documents file-based compilation flow, YAML generation, and lock file writing
  • CompileWorkflowData() - documents in-memory compilation for pre-parsed data, highlights use cases (testing, programmatic generation)

Helper function (compiler_jobs.go):

  • shouldAddCheckoutStep() - documents decision logic for checkout step inclusion across dev/release/script modes

Package documentation (compiler_orchestrator.go):

  • Added overview of 5-module architecture (engine detection, frontmatter parsing, tool config, workflow generation)

Example

$ go doc pkg/workflow.Compiler.CompileWorkflow
func (c *Compiler) CompileWorkflow(markdownPath string) error
    CompileWorkflow compiles a workflow markdown file into a GitHub Actions YAML
    file. It reads the file from disk, parses frontmatter and markdown sections,
    and generates the corresponding workflow YAML.

    The compilation process includes:
      - Reading and parsing the markdown file
      - Extracting frontmatter configuration
      - Validating workflow configuration
      - Generating GitHub Actions YAML
      - Writing the compiled workflow to a .lock.yml file

Note: Issue mentioned containsRuntimeImports() but this is a test-only helper in runtime_import_checkout_test.go, already documented appropriately.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Add missing godoc comments to compiler functions</issue_title>
<issue_description>### Description

Several compiler functions lack godoc comments, making it harder for developers to understand their purpose and usage without reading implementation details. Adding documentation improves code discoverability and maintainability.

Missing documentation:

  • compiler.go: CompileWorkflow(), CompileWorkflowData()
  • compiler_jobs.go: shouldAddCheckoutStep(), containsRuntimeImports()
  • compiler_orchestrator.go: Package-level documentation explaining 5-module architecture

Suggested Changes

Add godoc comments following Go documentation conventions:

1. Document public API functions:

// CompileWorkflow compiles a workflow markdown file into a GitHub Actions YAML file.
// It reads the file from disk, parses frontmatter and markdown sections, and generates
// the corresponding workflow YAML. Returns the compiled workflow data or an error.
func CompileWorkflow(filepath string) (*WorkflowData, error) { ... }

// CompileWorkflowData compiles pre-parsed workflow content into GitHub Actions YAML.
// Unlike CompileWorkflow, this accepts already-parsed frontmatter and markdown content
// rather than reading from disk. Useful for testing and programmatic workflow generation.
func CompileWorkflowData(frontmatter map[string]any, markdown string) (*WorkflowData, error) { ... }

2. Document helper functions:

// shouldAddCheckoutStep returns true if the workflow requires a checkout step.
// A checkout is needed when the workflow references runtime imports or custom actions.
func shouldAddCheckoutStep(...) bool { ... }

// containsRuntimeImports checks if the workflow configuration contains runtime import macros.
// Runtime imports are denoted by the pattern: ${{ runtime-import('file.yml') }}
func containsRuntimeImports(...) bool { ... }

3. Add package documentation to orchestrator:

// Package compiler_orchestrator implements the workflow compilation orchestration.
// It is split into 5 focused modules:
//   - orchestrator.go: Shared logger and constants
//   - orchestrator_engine.go: Engine detection and setup
//   - orchestrator_frontmatter.go: Frontmatter parsing and validation
//   - orchestrator_tools.go: Tool configuration and MCP server setup
//   - orchestrator_workflow.go: Main workflow orchestration and YAML generation
//
// The orchestrator follows a phased approach with typed result structures
// for clear data flow between compilation stages.

Files Affected

  • pkg/workflow/compiler.go (2 function comments needed)
  • pkg/workflow/compiler_jobs.go (2 helper function comments needed)
  • pkg/workflow/compiler_orchestrator.go (package-level comment needed)

Success Criteria

  • All public functions have godoc comments
  • Helper functions have clear purpose descriptions
  • Package-level documentation explains orchestrator architecture
  • Comments follow Go documentation conventions
  • go doc command shows helpful output for all functions

Source

Extracted from Daily Compiler Code Quality Report discussion github/gh-aw#13034

Finding excerpt:

"Documentation gaps: Some helper functions lack godoc comments (affects all files)... Add godoc comments for CompileWorkflow(), CompileWorkflowData(), shouldAddCheckoutStep(), containsRuntimeImports()"

Priority

Low - Improves developer experience but not critical for functionality. Quick win (30-45 minutes effort).

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 9, 2026, 9:06 AM UTC

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 8, 2026 09:51
- Enhanced CompileWorkflow() documentation with detailed description
- Enhanced CompileWorkflowData() documentation with usage context
- Enhanced shouldAddCheckoutStep() documentation with decision logic
- Added package-level documentation to compiler_orchestrator.go
- All comments follow Go documentation conventions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
All requested godoc comments have been added and validated:
- CompileWorkflow() enhanced with detailed documentation
- CompileWorkflowData() enhanced with usage context
- shouldAddCheckoutStep() enhanced with decision logic
- Package-level documentation added to compiler_orchestrator.go
- containsRuntimeImports() verified as test-only helper (already documented)

All validation passed:
- make fmt: ✓
- make lint: ✓
- make build: ✓
- make test-unit: ✓
- go doc output verified for all functions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add missing godoc comments to compiler functions Add missing godoc comments to compiler functions Feb 8, 2026
Copilot AI requested a review from pelikhan February 8, 2026 09:58
@pelikhan pelikhan marked this pull request as ready for review February 8, 2026 12:51
Copilot AI review requested due to automatic review settings February 8, 2026 12:51
@pelikhan pelikhan merged commit 23541bf into main Feb 8, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/add-godoc-comments-to-compiler-functions branch February 8, 2026 12:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds/updates GoDoc documentation intended to improve discoverability of core workflow compiler/orchestrator APIs via go doc, plus a small docs table correction.

Changes:

  • Added/expanded GoDoc comments for (*Compiler).CompileWorkflow and (*Compiler).CompileWorkflowData.
  • Added GoDoc for (*Compiler).shouldAddCheckoutStep.
  • Added orchestrator architecture overview comment to compiler_orchestrator.go; updated docs engine label for “Smoke Project”.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg/workflow/compiler_orchestrator.go Adds package-level comment describing the compiler orchestrator module breakdown.
pkg/workflow/compiler_jobs.go Documents checkout-step decision helper (shouldAddCheckoutStep).
pkg/workflow/compiler.go Documents the main compiler entrypoints for file-based and in-memory compilation flows.
docs/src/content/docs/agent-factory-status.mdx Updates the engine label for the Smoke Project workflow in the status table.
Comments suppressed due to low confidence (2)

pkg/workflow/compiler_orchestrator.go:9

  • The module list in this comment doesn’t match the actual orchestrator file names in this package (e.g., compiler_orchestrator_engine.go, compiler_orchestrator_tools.go, etc.). As-written, it points readers to non-existent orchestrator_*.go files. Update the list to reflect the real filenames so go doc guidance is actionable.
// The compiler orchestrator is split into 5 focused modules for maintainability:
//
//   - orchestrator.go: Shared logger and constants used across orchestrator modules
//   - orchestrator_engine.go: Engine detection, validation, and setup logic
//   - orchestrator_frontmatter.go: Frontmatter parsing and validation
//   - orchestrator_tools.go: Tool configuration and MCP server setup
//   - orchestrator_workflow.go: Main workflow orchestration and YAML generation

pkg/workflow/compiler.go:446

  • This docstring describes accepting "already-parsed frontmatter and markdown content", but the function actually accepts a single *WorkflowData. Also, it implies output is always written to a .lock.yml file, but writeWorkflowOutput skips writing when --no-emit is enabled. Consider rephrasing to match the parameters/behavior precisely so the GoDoc doesn’t overpromise.
// CompileWorkflowData compiles pre-parsed workflow content into GitHub Actions YAML.
// Unlike CompileWorkflow, this accepts already-parsed frontmatter and markdown content
// rather than reading from disk. This is useful for testing and programmatic workflow generation.
//
// The compilation process includes:
//   - Validating workflow configuration and features
//   - Checking permissions and tool configurations
//   - Generating GitHub Actions YAML structure
//   - Writing the compiled workflow to a .lock.yml file
//
// This function avoids re-parsing when workflow data has already been extracted,
// making it efficient for scenarios where the same workflow is compiled multiple times
// or when workflow data comes from a non-file source.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +14
// Package workflow implements workflow compilation orchestration.
//
// The compiler orchestrator is split into 5 focused modules for maintainability:
//
// - orchestrator.go: Shared logger and constants used across orchestrator modules
// - orchestrator_engine.go: Engine detection, validation, and setup logic
// - orchestrator_frontmatter.go: Frontmatter parsing and validation
// - orchestrator_tools.go: Tool configuration and MCP server setup
// - orchestrator_workflow.go: Main workflow orchestration and YAML generation
//
// The orchestrator follows a phased approach with typed result structures
// for clear data flow between compilation stages. Each module handles a specific
// concern in the compilation pipeline, making the codebase easier to understand
// and maintain.
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file adds a second Package workflow ... comment. Because compiler_orchestrator.go sorts before doc.go, go doc pkg/workflow will likely show this orchestrator-specific text instead of the broader package documentation in pkg/workflow/doc.go. Consider removing the Package workflow header here (make it a regular file/module comment), or move/merge the orchestrator architecture section into doc.go so the package docs stay authoritative and accurate for the whole package.

This issue also appears on line 3 of the same file.

Copilot uses AI. Check for mistakes.
// CompileWorkflow converts a markdown workflow to GitHub Actions YAML
// CompileWorkflow compiles a workflow markdown file into a GitHub Actions YAML file.
// It reads the file from disk, parses frontmatter and markdown sections, and generates
// the corresponding workflow YAML. Returns the compiled workflow data or an error.
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring says this function "Returns the compiled workflow data or an error", but the signature returns only error. This is misleading in go doc output; adjust the comment to describe that it compiles and writes the lock YAML (and returns an error on failure).

This issue also appears on line 434 of the same file.

Suggested change
// the corresponding workflow YAML. Returns the compiled workflow data or an error.
// the corresponding workflow YAML, writing it to a .lock.yml file and returning an error on failure.

Copilot uses AI. Check for mistakes.
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.

[Code Quality] Add missing godoc comments to compiler functions

2 participants