Documentation
¶
Overview ¶
Package docs is a thin layer over memgraph that models documents as trees of typed nodes (headings, paragraphs, lists, media, etc.) connected by ordered doc.contains edges. The package provides a Builder for writing document trees into a memgraph.Store and a renderer for emitting them as markdown. See DESIGN.md for the conceptual model.
Index ¶
- Constants
- type AppendCodeInput
- type AppendDividerInput
- type AppendHeadingInput
- type AppendListInput
- type AppendMediaInput
- type AppendParagraphInput
- type AppendQuoteInput
- type Builder
- func (b *Builder) AppendCode(ctx context.Context, in AppendCodeInput) (NodeRef, error)
- func (b *Builder) AppendDivider(ctx context.Context, in AppendDividerInput) (NodeRef, error)
- func (b *Builder) AppendHeading(ctx context.Context, in AppendHeadingInput) (NodeRef, error)
- func (b *Builder) AppendList(ctx context.Context, in AppendListInput) (NodeRef, error)
- func (b *Builder) AppendMedia(ctx context.Context, in AppendMediaInput) (NodeRef, error)
- func (b *Builder) AppendParagraph(ctx context.Context, in AppendParagraphInput) (NodeRef, error)
- func (b *Builder) AppendQuote(ctx context.Context, in AppendQuoteInput) (NodeRef, error)
- func (b *Builder) CreateDocument(ctx context.Context, in CreateDocumentInput) (DocumentRef, error)
- func (b *Builder) GetOutline(ctx context.Context, docID memgraph.LineageID, maxDepth int) (Outline, error)
- func (b *Builder) ListDocuments(ctx context.Context, graphID memgraph.GraphID) ([]DocumentRef, error)
- func (b *Builder) Move(ctx context.Context, in MoveInput) error
- func (b *Builder) RenderMarkdown(ctx context.Context, docID memgraph.LineageID) (string, error)
- func (b *Builder) UpdateText(ctx context.Context, in UpdateTextInput) (NodeRef, error)
- type CreateDocumentInput
- type DocumentRef
- type MoveInput
- type NodeRef
- type Outline
- type OutlineNode
- type UpdateTextInput
Constants ¶
const ( KindDocument = "doc.document" KindHeading = "doc.heading" KindParagraph = "doc.paragraph" KindList = "doc.list" KindListItem = "doc.list_item" KindCodeBlock = "doc.code_block" KindQuote = "doc.quote" KindMedia = "doc.media" KindDivider = "doc.divider" )
Node kinds used by memgraph-docs. All are namespaced with `doc.` so they don't collide with kinds from other clients sharing the same memgraph deployment.
const ( MediaImage = "image" MediaVideo = "video" MediaAudio = "audio" MediaFile = "file" )
Media kinds used by docs.media nodes' metadata.kind field.
const EdgeContains = "doc.contains"
Edge kind connecting parents to children in a document tree.
const MaxHeadingLevel = 6
MaxHeadingLevel is the deepest CommonMark heading level we accept.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppendCodeInput ¶
type AppendDividerInput ¶
type AppendHeadingInput ¶
type AppendListInput ¶
type AppendMediaInput ¶
type AppendParagraphInput ¶
type AppendQuoteInput ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is the high-level write/read API for documents stored in a memgraph.Store. All operations are safe for concurrent use as long as the underlying Store is.
func NewBuilder ¶
NewBuilder returns a Builder bound to the given Store. The Builder does not own the Store; callers are responsible for closing it.
func (*Builder) AppendCode ¶
func (*Builder) AppendDivider ¶
func (*Builder) AppendHeading ¶
func (*Builder) AppendList ¶
AppendList creates a list node and its item children in sequence. If item creation fails partway through, earlier writes are NOT rolled back — memgraph doesn't expose multi-write transactions at the Store level. For v0.1 this is acceptable; clients can detect partial failure via the count in the returned NodeRef metadata.
func (*Builder) AppendMedia ¶
func (*Builder) AppendParagraph ¶
func (*Builder) AppendQuote ¶
func (*Builder) CreateDocument ¶
func (b *Builder) CreateDocument(ctx context.Context, in CreateDocumentInput) (DocumentRef, error)
func (*Builder) GetOutline ¶
func (b *Builder) GetOutline(ctx context.Context, docID memgraph.LineageID, maxDepth int) (Outline, error)
GetOutline returns the document's structural tree. maxDepth limits how deep the traversal goes; 0 means unlimited.
func (*Builder) ListDocuments ¶
func (*Builder) Move ¶
Move reparents a node and/or reorders it among its siblings. It rewrites the single inbound doc.contains edge for the node (deletes and recreates it), and compacts sibling ordinals to 1..N at both the old and new parents so numbers stay small.
func (*Builder) RenderMarkdown ¶
RenderMarkdown walks the document tree and emits a CommonMark string. Unknown kinds render as plain paragraphs.
func (*Builder) UpdateText ¶
type CreateDocumentInput ¶
type DocumentRef ¶
type DocumentRef struct {
LineageID memgraph.LineageID
GraphID memgraph.GraphID
Title string
Author string
Abstract string
CreatedAt time.Time
}
DocumentRef summarizes a document for listing.
type NodeRef ¶
type NodeRef struct {
LineageID memgraph.LineageID
GraphID memgraph.GraphID
Kind string
Ordinal int
}
NodeRef is the public ID + minimal metadata returned from write operations.
type Outline ¶
type Outline struct {
Node OutlineNode `json:"node"`
Children []Outline `json:"children,omitempty"`
}
Outline summarizes the structural skeleton of a document — headings and container nodes, without paragraph or code bodies. Used by docs_get_outline.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
memgraph-docs
command
Command memgraph-docs is the CLI entrypoint for the memgraph-docs MCP server.
|
Command memgraph-docs is the CLI entrypoint for the memgraph-docs MCP server. |
|
Package mcp exposes a memgraph-docs Builder as a Model Context Protocol server.
|
Package mcp exposes a memgraph-docs Builder as a Model Context Protocol server. |