Help us shape the future of Go! Take the 2026 Go Developer Survey

importdocs

package
v0.9.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package importdocs copies a folder of markdown docs into a vault as notes, and keeps the copies in step with the docs on every re-run.

The doc is the source of truth; its note is a projection. Each note carries the doc as `paths:` (so reading the doc brings the note) and as `source:` plus `source_hash:` (so a re-run knows what changed). Copying rather than mounting keeps every write inside the vault's confinement — see docs/specs in the research repo, plan item 6.

Index

Constants

View Source
const ImportedDir = "imported"

ImportedDir is the vault folder imported notes live under.

Variables

View Source
var ErrNoMarkdown = errors.New("no markdown files")

ErrNoMarkdown reports a source folder with nothing to import.

Functions

This section is empty.

Types

type Action

type Action string

Action is what an import did, or would do, with one doc or note.

const (
	Added     Action = "added"
	Updated   Action = "updated"
	Unchanged Action = "unchanged"
	// Orphaned is a note whose doc is gone. It stays until --prune.
	Orphaned Action = "orphaned"
	Pruned   Action = "pruned"
	// Conflict is a note edited by hand whose doc also changed. It is kept;
	// --force overwrites it.
	Conflict Action = "conflict"
	// Skipped is a doc or note the import will not touch: a symlink, a file
	// it did not write, or an id another doc already took.
	Skipped Action = "skipped"
)

The actions an import reports.

type Entry

type Entry struct {
	Action Action `json:"action"`
	// Note is the note's vault-relative path.
	Note string `json:"note"`
	// Source is the doc as `<repo>:<path>`, empty for a skipped note.
	Source string `json:"source,omitempty"`
	Reason string `json:"reason,omitempty"`
}

Entry is one line of the report.

type Options

type Options struct {
	DryRun bool
	Prune  bool
	Force  bool
	// Excludes is the vault's exclude list: a note it would hide from the
	// index is not written.
	Excludes []string
}

Options change what an import writes.

type Result

type Result struct {
	Entries []Entry `json:"entries"`
	DryRun  bool    `json:"dry_run"`
}

Result is the whole report.

func Import

func Import(src Source, vaultRoot string, opts Options) (*Result, error)

Import brings the docs under src into vaultRoot and reports what it did.

func (*Result) Changed

func (r *Result) Changed() []string

Changed returns the vault-relative paths written or removed, which the caller re-indexes.

func (*Result) Count

func (r *Result) Count(a Action) int

Count returns how many entries took action a.

type Source

type Source struct {
	Dir string
	// Repo is the repository name `paths:` entries use.
	Repo string
	// Prefix is Dir relative to the repository root, "" at the root.
	Prefix string
}

Source names the docs to import. The command layer resolves Repo and Prefix from the repository around Dir, as `paths:` does.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL