You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
## Overview
2
2
3
-
Archivist generates data structure definitions from JSON files for any kind of programming language. Besides that, it also provides a library for golang to cut the job of managing runtime configs down to several lines of code.
3
+
Archivist generates data structure definitions from JSON files for any kind of programming language. It also provides a library for golang to reduce the job of managing runtime configs down to just several lines of code.
4
4
5
5
## Contents
6
6
@@ -21,7 +21,7 @@ Archivist generates data structure definitions from JSON files for any kind of p
21
21
-[Subcommand: paths](#paths)
22
22
-[Subcommand: orphan](#orphan)
23
23
-[Subcommand: tpls](#tpls)
24
-
-[Generate Data Structure Definitions for Another Programming Language](#code-templates)
24
+
-[Generating Data Structure Definitions for Another Programming Language](#code-templates)
25
25
-[FAQ](#faq)
26
26
27
27
<aname="features"></a>
@@ -32,10 +32,10 @@ Archivist generates data structure definitions from JSON files for any kind of p
32
32
* Guess out the most suitable data type for arbitrary JSON field
33
33
* Customize data type via [.meta](#.meta) file. E.g. replace struct with map[string]...
34
34
* Support extended data types via [.meta](#.meta) file, including [reference](#reference), [datetime](#datetime), [duration](#duration) and [i18n](#i18n)
35
-
* Process [.js](#.js) file in addition to .json file, which is much friendly to edit for human-kind
35
+
* Process [.js](#.js) file in addition to .json file, which is much friendly to edit manually
36
36
* Show all node paths and data types with the '[paths](#paths)' subcommand
37
37
* Detect and drop orphan generated files with the '[orphan](#orphan)' subcommand
38
-
* Customize [code templates](#code-templates), by which any kind of programming language can benefit from the tool
38
+
* Customize [code templates](#code-templates), by which any programming language can benefit from
39
39
40
40
#### Library
41
41
@@ -57,7 +57,7 @@ Note: To use [.js](#.js) as config file, you must have <a href="https://nodejs.o
57
57
58
58
#### Install from Binary Release
59
59
60
-
Download a binary release suitable for your system, unzip it, and then update your PATH environment variable in order that archivist can run from anywhere.
60
+
Download a binary release suitable for your system, unzip it, and then update your PATH environment variable so that archivist can run from anywhere.
61
61
62
62
#### Install from Source
63
63
@@ -280,7 +280,7 @@ map[1:hello 2:world]
280
280
<aname=".meta"></a>
281
281
## Meta File
282
282
283
-
In most cases, archivist automatically determines the data type of each JSON field. But sometimes, the data type of guess is not desired, or you prefer to use an [extended data type](#extended), you may give a .meta file to customize that.
283
+
In most cases, archivist automatically determines the data type of each JSON field. But sometimes, if the data type of guess were not desired, or you prefer to use an [extended data type](#extended), you may give a .meta file to customize that.
284
284
285
285
Suppose you have a file `abc.json`, and you want to change the data type of a JSON field. Just create a file `abc.meta` under the same directory where `abc.json` lies in. Archivist will parse it along with `abc.json` and apply the instructions in it.
286
286
@@ -290,7 +290,7 @@ Suppose you have a file `abc.json`, and you want to change the data type of a JS
290
290
path type comment
291
291
```
292
292
293
-
-**path**: path of the field from root. It is not easy to spell out the path of a field, therefore archivist provides a subcommand, [paths](#paths), to make it easy, with which all you need to do is copy/paste.
293
+
-**path**: path of the field from root. It is not easy to spell out the path of a field, therefore archivist provides a subcommand, [paths](#paths), to simplify it, with which all you need to do is copy & paste.
The referenced config file must satisfy the following criterion: its corresponding type must be map, the key type must be int64
387
+
The referenced config file must meet the following criterion: its corresponding type must be map, the key type must be int64
388
388
and the value type must be struct.
389
389
390
390
<aname="datetime"></a>
@@ -520,7 +520,7 @@ Number: 12,345.60
520
520
<aname="conf-group"></a>
521
521
## Config Group and Subgroup
522
522
523
-
Different operating environments may need more or less different configs. The config files under the root directory are base configs. Config group and subgroup are designed to overwrite base configs at file-level and content-level. By convention, each subfolder under the root directory is a config group and each subfolder under a config group directory is a config subgroup. In the following example, _local_, _develop_ and _release_ are config groups, _subgroup1_ and _subgroup2_ are config subgroups.
523
+
Different operating environments may need different configs more or less. The config files under the root directory are base configs. Config group and subgroup are designed to overwrite base configs at file-level and content-level. By convention, each subfolder under the root directory is a config group and each subfolder under a config group directory is a config subgroup. In the following example, _local_, _develop_ and _release_ are config groups, _subgroup1_ and _subgroup2_ are config subgroups.
524
524
525
525
```
526
526
bar
@@ -601,7 +601,7 @@ For more information, please refer to [Hot Patching](#patch).
601
601
<aname="easyjson"></a>
602
602
## Fast Loading
603
603
604
-
<ahref="https://github.com/edwingeng/easyjson-alt"target="_blank">easyjson</a> can dramatically increase the speed of config loading. Turn on `--x-easyjson` to earn the benefit.
604
+
<ahref="https://github.com/edwingeng/easyjson-alt"target="_blank">easyjson</a> can dramatically increase the speed of config loading. Turn on `--x-easyjson` to enable the benefit.
Sometimes, raw configs does not fit your needs well. You have to write some code to organize raw configs and store the result for later use. Config extension is designed for that.
656
656
657
-
Perhaps you have found that archivist generated a new file named `collectionExtension.go` and added an `Extention` field for the `Collection` struct. After the first code generation, archivist will never touch `collectionExtension.go` again, so you can udpate the file freely without worrying about losing your code.
657
+
Perhaps you have found that archivist generated a new file named `collectionExtension.go` and added an `Extension` field for the `Collection` struct. After the first code generation, archivist will never touch `collectionExtension.go` again, so you can update the file freely without worrying about losing your code.
658
658
659
-
In short, you can organize raw configs with the reload callback, which is invoked each time after `LoadCollection` succeeds, and store the result into the `Extention` struct.
659
+
In short, you can organize raw configs with the reload callback, which is invoked each time after `LoadCollection` succeeds, and store the result into the `Extension` struct.
## Generate Data Structure Definitions for Another Programming Language
747
+
## Generating Data Structure Definitions for Another Programming Language
748
748
749
749
1. Save the built-in code templates to files with the [tpls](#tpls) subcommand.
750
750
2. Modify code templates according to your needs. Syntax reference: <ahref="https://godoc.org/text/template"target="_blank">https://godoc.org/text/template</a>.
- **Why JSON? Why not YAML, TOML, XML, CSV, ...?**
885
885
886
-
JSON is simple yet good enough. It is widely supported by all kinds of programming languages. It supports hierarchical data structure. It provides no choice between field and property when you add a piece of data into a struct. JSON files are not hard to compare and merge.
886
+
JSON is simple yet good enough. It is widely supported by all kinds of programming languages. It supports hierarchical data structure. It provides no choice between field and property when you add a piece of data into a struct. JSON files are easy to compare and merge.
887
887
888
-
JSON is not perfect. It has too many double quotation marks. It does not support comment. The last item in a {}/[] must have no trailing comma. That is why archivist also supports Javascript as an auxiliary format. The data definition syntax of Javascript is very close to JSON.
888
+
JSON is not perfect. It has too many double quotation marks. It does not support comments. The last item in a {}/[] must have no trailing comma. That is why archivist also supports Javascript as an auxiliary format. The data definition syntax of Javascript is very close to JSON.
889
889
890
890
I'd like to support more file formats, but I have no time to do that. Contribution is welcome :)
891
891
892
892
- **The code templates are too sophisticated. How can I get started?**
893
893
894
-
The built-in code templates for golang are fully functional yet sophisticated. You can build your own templates in a much simpler way if you do not need so many features. We have other code templates written for `C#`, `Lua` and `EmmyLua`, but they are tightly coupled with our products and are not proper to open source.
894
+
The built-in code templates for golang are fully functional. You can build your own templates in a much simpler way if you do not need so many features. We have other code templates written for `C#`, `Lua` and `EmmyLua`, but they are tightly coupled with our products and are not proper for opening source.
895
895
896
896
Here is a hello-world-like code template of `struct.tpl`:
0 commit comments