Skip to content

Define structured docs model and add unit tests #3

@RPG-Alex

Description

@RPG-Alex

Summary

Define and expose a structured documentation model over SQL files (tables + columns + docs), and add tests to verify correct association of comments to AST elements.

Proposed data structures

struct SqlDocs {
    tables: Vec<TableDoc>,
}

struct TableDoc {
    name: String,
    doc: Option<String>,
    columns: Vec<ColumnDoc>,
}

struct ColumnDoc {
    name: String,
    doc: Option<String>,
}

Requirements

  • Use PathBuf internally for file references to avoid lifetime issues (where needed).
  • Ensure the model can be constructed from:
    • Parsed statements (sqlparser AST)
    • Extracted comment blocks from the original source text.

Tasks

  • Implement SqlDocs, TableDoc, and ColumnDoc as the public-facing documentation model.
  • Add constructors/builders to build SqlDocs from:
    • A parsed SQL AST + raw source text.
    • (Eventually) multiple files / a SqlFileSet.
  • Add unit tests:
    • Comments directly above CREATE TABLE become TableDoc::doc.
    • Comments directly above a column definition become ColumnDoc::doc.
    • Inline comments on the same line as SQL are not treated as docs (unless you explicitly decide otherwise).
    • Interstitial comments (e.g. comments separated by blank lines or other SQL statements) are ignored as docs.
    • Multi-table fixtures where each table gets the correct comment block.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions