romanus

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 11 Imported by: 0

README

GoDoc Build Status Go Report Card codecov

romanus

Golang library containing the entire Roman Catechism of the Council of Trent.

Documentation here: https://godoc.org/github.com/mborders/romanus

Structure

Each Part of the Catechism has its own Introduction plus a list of Articles. Each Article has a navigable short Title (e.g. "Baptism", "The First Commandment", "I Believe in God, the Father Almighty, Creator of Heaven and Earth") and a Heading preserving the formal all-caps heading from the original text (which includes the quoted commandment / petition scripture for Parts 3 and 4). Articles contain Sections, which contain Paragraphs.

Example Usage

// Create a new catechism instance
c := romanus.NewCatechism()

// Get Part 1
part, err := c.GetPart(1)

// Get the introduction for Part 1 (separate from its articles)
intro, err := c.GetIntroduction(1)
s, err := c.GetIntroductionSection(1, 1)
p, err := c.GetIntroductionParagraph(1, 1, 1)

// Get Part 1, Article 1 — the First Article of the Creed
a, err := c.GetArticle(1, 1)
fmt.Print(a.Title)   // "I Believe in God, the Father Almighty, Creator of Heaven and Earth"
fmt.Print(a.Heading) // "ARTICLE I : \"I BELIEVE IN GOD, THE FATHER ALMIGHTY, CREATOR OF HEAVEN AND EARTH\""

// Get Part 1, Article 1, Section 1
s, err = c.GetSection(1, 1, 1)

// Get Part 1, Article 1, Section 1, Paragraph 1
p, err = c.GetParagraph(1, 1, 1, 1)
fmt.Print(p.Text)

// Search for paragraphs
r := c.Search("I believe", 10)
fmt.Print(r[0].Part.PartNumber)
fmt.Print(r[0].Article.ArticleNumber) // nil when the hit is inside an Introduction
fmt.Print(r[0].Section.SectionNumber)
fmt.Print(r[0].Paragraph.ParagraphNumber)
fmt.Print(r[0].Paragraph.Text)
fmt.Print(r[0].String()) // "Part 4, Article 2, Section 3, Paragraph 1"

Rebuilding the source data

catechism.tar.gz is the packaged source data, normalized so each Part exposes a separate Introduction and Article numbering reflects how a reader would navigate the Roman Catechism (Article 1 of Part 1 = the First Article of the Creed, not a preface). To regenerate the tarball after a future data change, run python3 scripts/rebuild_data.py.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Title         string    `json:"title"`
	Heading       string    `json:"heading"`
	ArticleNumber uint8     `json:"articleNumber"`
	Sections      []Section `json:"sections"`
}

Article contains a list of sections. Heading holds the formal all-caps heading from the original Roman Catechism (e.g. the quoted commandment or petition text); Title is the navigable short form.

type ArticleSummary

type ArticleSummary struct {
	Title         string `json:"title"`
	Heading       string `json:"heading"`
	ArticleNumber uint8  `json:"articleNumber"`
}

ArticleSummary contains metadata for an article

type Catechism

type Catechism struct {
	Parts       []Part        `json:"-"`
	PartSummary []PartSummary `json:"parts"`
	// contains filtered or unexported fields
}

Catechism contains a list of parts

func NewCatechism

func NewCatechism() *Catechism

NewCatechism parses and creates a new catechism instance

func (*Catechism) GetArticle

func (c *Catechism) GetArticle(partNumber, articleNumber int) (*Article, error)

GetArticle obtains an article within the catechism by its number

func (*Catechism) GetIntroduction added in v0.2.0

func (c *Catechism) GetIntroduction(partNumber int) (*Introduction, error)

GetIntroduction obtains the introduction for a given part

func (*Catechism) GetIntroductionParagraph added in v0.2.0

func (c *Catechism) GetIntroductionParagraph(partNumber, sectionNumber, paragraphNumber int) (*Paragraph, error)

GetIntroductionParagraph obtains a paragraph within a part's introduction

func (*Catechism) GetIntroductionSection added in v0.2.0

func (c *Catechism) GetIntroductionSection(partNumber, sectionNumber int) (*Section, error)

GetIntroductionSection obtains a section within a part's introduction

func (*Catechism) GetParagraph

func (c *Catechism) GetParagraph(partNumber, articleNumber, sectionNumber, paragraphNumber int) (*Paragraph, error)

GetParagraph obtains a paragraph within the catechism by its number

func (*Catechism) GetPart

func (c *Catechism) GetPart(partNumber int) (*Part, error)

GetPart obtains a part within the catechism by its number

func (*Catechism) GetSection

func (c *Catechism) GetSection(partNumber, articleNumber, sectionNumber int) (*Section, error)

GetSection obtains a section within the catechism by its number

func (*Catechism) Search

func (c *Catechism) Search(query string, maxResults int) []SearchNode

Search finds top matching paragraphs based on the given query. The number of search results is restricted by maxResults.

type Introduction added in v0.2.0

type Introduction struct {
	Sections []Section `json:"sections"`
}

Introduction contains preface sections for a part

type Paragraph

type Paragraph struct {
	ParagraphNumber uint8  `json:"paragraphNumber"`
	Text            string `json:"text"`
}

Paragraph contains text

type Part

type Part struct {
	Title        string       `json:"title"`
	PartNumber   uint8        `json:"partNumber"`
	Introduction Introduction `json:"introduction"`
	Articles     []Article    `json:"articles"`
}

Part contains a per-part introduction and a list of articles

type PartSummary

type PartSummary struct {
	Title      string           `json:"title"`
	PartNumber uint8            `json:"partNumber"`
	Articles   []ArticleSummary `json:"articles"`
}

PartSummary contains metadata for a part

type SearchNode

type SearchNode struct {
	Part      *Part
	Article   *Article
	Section   *Section
	Paragraph *Paragraph
}

SearchNode represents a search result for a given paragraph inquiry. Article is nil when the match falls inside a part's Introduction.

func (*SearchNode) String

func (s *SearchNode) String() string

String creates a string representation for the SearchNode, ex. Part 1, Article 1, Section 1, Paragraph 1; for hits inside a part's Introduction the form is Part N, Introduction, Section M, Paragraph K.

type Section

type Section struct {
	Title         string      `json:"title"`
	SectionNumber uint8       `json:"sectionNumber"`
	Paragraphs    []Paragraph `json:"paragraphs"`
}

Section contains a list of paragraphs

Jump to

Keyboard shortcuts

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