diff options
| author | Shulhan <ms@kilabit.info> | 2024-08-13 07:35:12 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-08-13 07:38:35 +0700 |
| commit | b8fdcc2be2fcae1bfd3dd62b8bc2d4abe75e78d0 (patch) | |
| tree | 6572805cdfff4a9fa6c2a17337c977ae4a202674 | |
| parent | 741463b99f14f1869c804cd4c6b15be155a7c27e (diff) | |
| download | asciidoctor-go-b8fdcc2be2fcae1bfd3dd62b8bc2d4abe75e78d0.tar.xz | |
all: rename struct "AttributeEntry" to "DocumentAttribute"
This is to make the struct is clear that it represent the document
attribute.
| -rw-r--r-- | document.go | 4 | ||||
| -rw-r--r-- | document_attribute.go (renamed from attribute_entry.go) | 12 | ||||
| -rw-r--r-- | parser_test.go | 10 |
3 files changed, 13 insertions, 13 deletions
diff --git a/document.go b/document.go index 47d2c85..50be70f 100644 --- a/document.go +++ b/document.go @@ -31,7 +31,7 @@ type Document struct { preamble *element content *element - Attributes AttributeEntry + Attributes DocumentAttribute sectnums *sectionCounters // titleID is the reverse of anchors, it contains mapping of title and @@ -76,7 +76,7 @@ func newDocument() (doc *Document) { TOCLevel: defTOCLevel, tocClasses: attributeClass{}, tocTitle: defTOCTitle, - Attributes: newAttributeEntry(), + Attributes: newDocumentAttribute(), classes: attributeClass{}, anchors: make(map[string]*anchor), titleID: make(map[string]string), diff --git a/attribute_entry.go b/document_attribute.go index 98db699..c7b2c83 100644 --- a/attribute_entry.go +++ b/document_attribute.go @@ -5,12 +5,12 @@ package asciidoctor import "strings" -// AttributeEntry contains the mapping of global attribute keys in the headers -// with its value. -type AttributeEntry map[string]string +// DocumentAttribute contains the mapping of global attribute keys in the +// headers with its value. +type DocumentAttribute map[string]string -func newAttributeEntry() AttributeEntry { - return AttributeEntry{ +func newDocumentAttribute() DocumentAttribute { + return DocumentAttribute{ MetaNameGenerator: `asciidoctor-go ` + Version, metaNameLastUpdateLabel: `Last updated`, metaNameLastUpdateValue: ``, @@ -21,7 +21,7 @@ func newAttributeEntry() AttributeEntry { } } -func (entry *AttributeEntry) apply(key, val string) { +func (entry *DocumentAttribute) apply(key, val string) { switch { case key[0] == '!': delete(*entry, strings.TrimSpace(key[1:])) diff --git a/parser_test.go b/parser_test.go index ffa055f..21e20f6 100644 --- a/parser_test.go +++ b/parser_test.go @@ -19,7 +19,7 @@ func TestGenerateID(t *testing.T) { var cases = []testCase{{ desc: `Without idprefix and idseparator`, doc: &Document{ - Attributes: AttributeEntry{}, + Attributes: DocumentAttribute{}, }, inputExp: map[string]string{ `a b c`: `a_b_c`, @@ -28,7 +28,7 @@ func TestGenerateID(t *testing.T) { }, { desc: `With idprefix`, doc: &Document{ - Attributes: AttributeEntry{ + Attributes: DocumentAttribute{ metaNameIDPrefix: `123`, }, }, @@ -39,7 +39,7 @@ func TestGenerateID(t *testing.T) { }, { desc: `With empty idseparator`, doc: &Document{ - Attributes: AttributeEntry{ + Attributes: DocumentAttribute{ metaNameIDSeparator: ``, }, }, @@ -50,7 +50,7 @@ func TestGenerateID(t *testing.T) { }, { desc: `With idseparator`, doc: &Document{ - Attributes: AttributeEntry{ + Attributes: DocumentAttribute{ metaNameIDSeparator: `-`, }, }, @@ -61,7 +61,7 @@ func TestGenerateID(t *testing.T) { }, { desc: `With idprefix and idseparator`, doc: &Document{ - Attributes: AttributeEntry{ + Attributes: DocumentAttribute{ metaNameIDPrefix: `id_`, metaNameIDSeparator: `-`, }, |
