комментарии и сообщения переведены на английский

- комментарии, тексты ошибок, вывод CLI и сообщения тестов теперь на английском
- по-русски остались только литералы словаря ru и содержимое фикстур: это
  данные под проверкой, а не текст инструмента
- согласование числительных в итоге упростилось до английского plural
This commit is contained in:
av
2026-07-27 10:04:27 +03:00
parent 0b8cc125b3
commit b2d07ae55d
17 changed files with 548 additions and 524 deletions
+33 -29
View File
@@ -1,11 +1,12 @@
// Package suite собирает набор конвенций в память: манифест, словарь языка и
// документы, которые язык употребляет.
// Package suite assembles a conventions suite in memory: its manifest, the
// vocabulary of its language, and the documents the language employs.
//
// Проверке подлежит всё, что язык употребляет: файлы конвенций и документ,
// которым набор ведёт себя сам. Список этих файлов даёт манифест — раздел
// живых префиксов, где у каждого префикса записан путь. Файл, который язык
// только цитирует (описание языка), в наборе не значится и проверок не
// получает.
// What is subject to checking is everything the language employs: the
// convention files and the document the suite governs itself by. The list of
// those files comes from the manifest, from the section of live prefixes where
// every prefix carries a path. A file the language merely quotes — the
// description of the language itself — is not listed in the suite and gets no
// checks.
package suite
import (
@@ -22,28 +23,28 @@ import (
"git.vakhrushev.me/av/convy/internal/manifest"
)
// Suite — загруженный набор.
// Suite is a loaded suite.
type Suite struct {
Root string
Manifest *manifest.Manifest
Vocab lang.Vocabulary
// Docs — документы набора в порядке живых префиксов.
// Docs holds the documents of the suite in the order of live prefixes.
Docs []*doc.Document
// ByPrefix — документ по префиксу из манифеста.
// ByPrefix maps a manifest prefix to its document.
ByPrefix map[string]*doc.Document
// Missing — префиксы, чей файл манифест объявляет, а файловой системы в
// нём нет.
// Missing lists the prefixes whose file the manifest declares while the
// file system holds none.
Missing map[string]string
// Unregistered — найденные в наборе файлы с шапкой, которых манифест не
// объявляет. Такой файл не проверяется и не собирается: для набора его
// нет, хотя автор считает иначе.
// Unregistered lists files found in the suite carrying front matter that
// the manifest does not declare. Such a file is neither checked nor
// assembled: for the suite it does not exist, however its author sees it.
Unregistered []string
// Broken — файлы, чью шапку не удалось разобрать.
// Broken lists files whose front matter could not be parsed.
Broken []error
}
// Load читает набор из директории root.
// Load reads a suite from directory root.
func Load(root string) (*Suite, error) {
m, err := manifest.Load(root)
if err != nil {
@@ -85,9 +86,10 @@ func Load(root string) (*Suite, error) {
return s, nil
}
// findUnregistered обходит набор и ищет файлы, записанные языком конвенций, но
// не объявленные в манифесте. Признак — ключ prefix в шапке, а не
// расположение файла: таксономию набор перестраивает, а шапка утверждает.
// findUnregistered walks the suite looking for files written in the conventions
// language yet absent from the manifest. The marker is the prefix key in the
// front matter rather than the location of the file: the suite rearranges its
// taxonomy, while the front matter asserts.
func (s *Suite) findUnregistered() error {
declared := make(map[string]bool)
for _, path := range s.Manifest.Prefixes.Live {
@@ -120,8 +122,9 @@ func (s *Suite) findUnregistered() error {
}
d, err := doc.Load(rel, name)
if err != nil {
// Шапки у файла нет или она сломана — для набора это не
// документ языка, а просто markdown рядом.
// The file carries no front matter, or it is broken — for the
// suite this is not a document of the language but plain
// markdown lying nearby.
return nil
}
if d.Front.Prefix != "" {
@@ -130,15 +133,15 @@ func (s *Suite) findUnregistered() error {
return nil
})
if err != nil {
return fmt.Errorf("обход набора: %w", err)
return fmt.Errorf("walking the suite: %w", err)
}
sort.Strings(s.Unregistered)
return nil
}
// Conventions отбирает документы конвенций — те, что несут тему и потому
// уезжают к потребителю. Документ без темы (набор ведёт им себя сам) проверки
// распространения не получает.
// Conventions picks out the convention documents — the ones that carry a topic
// and therefore travel to a consumer. A document without a topic, the one the
// suite governs itself by, gets no spread checks.
func (s *Suite) Conventions() []*doc.Document {
var out []*doc.Document
for _, d := range s.Docs {
@@ -149,7 +152,8 @@ func (s *Suite) Conventions() []*doc.Document {
return out
}
// Layers перечисляет слои темы — документы, объявившие это имя в шапке.
// Layers lists the layers of a topic — the documents that declared that name in
// their front matter.
func (s *Suite) Layers(topic string) []*doc.Document {
var out []*doc.Document
for _, d := range s.Docs {
@@ -160,13 +164,13 @@ func (s *Suite) Layers(topic string) []*doc.Document {
return out
}
// Prefix возвращает префикс, объявленный манифестом за документом.
// Prefix returns the prefix the manifest declares for a document.
func (s *Suite) Prefix(d *doc.Document) string {
prefix, _ := s.Manifest.PrefixOf(d.Path)
return prefix
}
// Exists проверяет, есть ли в наборе файл по пути от корня.
// Exists reports whether the suite holds a file at a path from its root.
func (s *Suite) Exists(rel string) bool {
_, err := os.Stat(filepath.Join(s.Root, filepath.FromSlash(rel)))
return err == nil