From 7e82a150b3485f9f9e14eb7dad4f44b09d66466c Mon Sep 17 00:00:00 2001 From: Eiji Onchi Date: Sun, 4 Nov 2018 15:36:12 +0900 Subject: [PATCH] Added documentation --- README.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 105 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5439569..af3d5d9 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,110 @@ -# Scholar -Reference Manager in Go +# Scholar Library +Go library to generate and manipulate bibliography entries. -**Right now is really unstable, use at your own risk.** +For the CLI program, click [here](https://github.com/cgxeiji/scholar/tree/master/scholar). -To install the CLI version, run: +## Usage +Scholar uses a YAML configuration file to load the types of entries to be used. +The basic structure of the file is as follows: + +```yaml +typeName: + desc: A brief description of the type. + req: + field1: A brief description of field1. + field2: A brief description of field2. + field3: A brief description of field3. + opt: + field1: A brief description of field1. + field2: A brief description of field2. + field3: A brief description of field3. +``` + +For example: +```yaml +article: + desc: An article in a journal, magazine, newspaper, or other periodical which forms a self-contained unit with its own title. + req: + author: Author(s) of the article. + title: Title of the article. + journaltitle: Title of the journal. + date: YYYY-MM-DD format. + opt: + editor: Editor(s) of the journal. + language: Language of the article. + series: Series of the journal. + volume: Volume of the journal. + number: Number of the journal. + issn: ISSN number of the article. + doi: DOI code of the article. + url: URL of the article. + urldate: Access date in YYY-MM-DD format. + +book: + desc: A single-volume book with one or more authors where the authors share credit for the work as a whole. + req: + author: Author(s) of the book. + title: Title of the book. + date: YYYY-MM-DD format. + opt: + editor: Editor(s) of the book. + publisher: Publisher of the book. + location: Location of the publisher. + language: Language of the book. + series: Series of the book. + volume: Volume of the book. + number: Number of the book. + pages: Number of pages is the book. + isbn: ISBN number of the book. + doi: DOI code of the book. + url: URL of the book. + urldate: Access date in YYY-MM-DD format. +``` + +To load the entry types to be used by Scholar, do: + +```go +func main() { + if err := scholar.LoadTypes("types.yaml"); err != nil { + // handle error + } +} +``` + +To create a new Entry struct, do: +```go + entry := scholar.NewEntry("article") +``` + +To change the type of an entry, do: +```go + entryArticle := scholar.NewEntry("article") + entryBook := scholar.Convert(entryArticle, "book") +``` + +To get a BibLaTex format reference, do: +```go + entry := scholar.NewEntry("article") + entry.Required["title"] = "The Article" + entry.Required["author'] = "Last, First and Other, Second" + entry.Required["journaltitle"] = "The Journal of Articles" + entry.Required["date"] = "2018" + + fmt.Println(entry.Bib()) ``` -go get github.com/cgxeiji/scholar/scholar ``` +output: + @article{last2018, + author = {Last, First and Other, Second}, + date = {2018}, + journaltitle = {The Journal of Articles}, + title = {The Article} + } +``` + + +## TODO + +- [ ] Return an error on `TypeNotFound` for `NewEntry()` +- [ ] Improve documentation