github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/docs/source/style_guide.md (about) 1 # Style guide for contributors 2 3 **Audience**: documentation writers and editors 4 5 While this style guide will also refer to best practices using ReStructured Text (also known as RST), in general we advise writing documentation in Markdown, as it's a more universally accepted documentation standard. Both formats are usable, however, and if you decide to write a topic in RST (or are editing an RST topic), be sure to refer to this style guide. 6 7 **When in doubt, use the docs themselves for guidance on how to format things.** 8 9 * [For RST formatting](http://hyperledger-fabric.readthedocs.io/en/{RTD_TAG}/channel_update_tutorial.html). 10 11 * [For Markdown formatting](http://hyperledger-fabric.readthedocs.io/en/{RTD_TAG}/peers/peers.html). 12 13 If you just want to look at how things are formatted, you can navigate to the Fabric repo to look at the raw file by clicking on `Edit on Github` link in the upper right hand corner of the page. Then click the `Raw` tab. This will show you the formatting of the doc. **Do not attempt to edit the file on Github.** If you want to make a change, clone the repo and follow the instructions in [Contributing](./CONTRIBUTING.html) for creating pull requests. 14 15 ## Word choices 16 17 **Avoid the use of the words "whitelist", "blacklist", "master", or "slave".** 18 19 Unless the use of these words is absolutely necessary (for example, when quoting a section of code that uses them), do not use these words. Either be more explicit (for example, describing what "whitelisting" actually does) or find alternate words such as "allowlist" or "blocklist". 20 21 **Tutorials should have a list of steps at the top.** 22 23 A list of steps (with links to the corresponding sections) at the beginning of a tutorial helps users find particular steps they're interested in. For an example, check out [Use private data in Fabric](./private-data/private-data.html). 24 25 **"Fabric", "Hechain" or "HLF"?** 26 27 The first usage should be “Hechain” and afterwards only “Fabric”. Don't use "HLF" or "Hyperledger" by itself. 28 29 **Chaincode vs. Chaincodes?** 30 31 One chaincode is a “chaincode”. If you’re talking about several chaincodes, use "chaincodes". 32 33 **Smart contracts?** 34 35 Colloquially, smart contracts are considered equivalent to chaincode, though at a technical level, it is more correct to say that a "smart contract" is the business logic inside of a chaincode, which encompasses the larger packaging and implementation. 36 37 **JSON vs .json?** 38 39 Use “JSON”. The same applies for any file format (for example, YAML). 40 41 **curl vs cURL.** 42 43 The tool is called “cURL”. The commands themselves are “curl” commands. 44 45 **Fabric CA.** 46 47 Do not call it "fabric-CA", "fabricCA", or FabricCA. It is the Fabric CA. The Fabric CA client binary can, however, be referred to as the `fabric-ca-client`. 48 49 **Raft and RAFT.** 50 51 "Raft" is not an acronym. Do not call it a "RAFT ordering service". 52 53 **Referring to the reader.** 54 55 It’s perfectly fine to use the “you” or “we”. Avoid using "I". 56 57 **Ampersands (&).** 58 59 Not a substitute for the word “and”. Avoid them unless you have a reason to use it (such as in a code snippet that includes it). 60 61 **Acronyms.** 62 63 The first usage of an acronym should be spelled out, unless it’s an acronym that’s in such wide usage this is unneeded. For example, “Software Development Kit (SDK)” on first usage. Then use “SDK” afterward. 64 65 **Try to avoid using the same words too often.** 66 67 If you can avoid using a word twice in one sentence, please do so. Not using it more than twice in a single paragraph is better. Of course sometimes it might not be possible to avoid this –-- a doc about the state database being used is likely to be replete with uses of the word “database” or “ledger”. But excessive usage of any particular word has a tendency to have a numbing effect on the reader. 68 69 **How should files be named?** 70 71 By using underscores between words. Also, tutorials should be named as such. For example, `identity_use_case_tutorial.md`. While not all files use this standard, new files should adhere to it. 72 73 ## Formatting and punctuation 74 75 **Line lengths.** 76 77 If you look at the raw versions of the documentation, you will see that many topics conform to a line length of roughly 70 characters. This restriction is no longer necessary, so you are free to make lines as long as you want. 78 79 **When to bold?** 80 81 Not too often. The best use of them is either as a summary or as a way of drawing attention to concepts you want to talk about. “A blockchain network contains a ledger, at least one chaincode, and peers”, especially if you’re going to be talking about those things in that paragraph. Avoid using them simply to emphasize a single word, as in something like "Blockchain networks **must** use proper security protocols". 82 83 **When to surround something in back tics `nnn`?** 84 85 This is useful to draw attention to words that either don’t make sense in plain English or when referencing parts of the code (especially if you’ve put code snippets in your doc). So for example, when talking about the fabric-samples directory, surround `fabric-samples` with back tics. Same with a code function like `hf.Revoker`. It might also make sense to put back tics around words that do make sense in plain English that are part of the code if you're referencing them in a code context. For example, when referencing an `attribute` as part of an Access Control List. 86 87 **Is it ever appropriate to use a dash?** 88 89 Dashes can be incredibly useful but they're not necessarily as technically appropriate as using separate declarative sentences. Let's consider this example sentence: 90 91 ``` 92 This leaves us with a trimmed down JSON object --- config.json, located in the fabric-samples folder inside first-network --- which will serve as the baseline for our config update. 93 ``` 94 95 There are a number of ways to present this same information, but in this case the dashes break up the information while keeping it as part of the same thought. If you use a dash, make sure to use the "em" dash, which is three times longer than a hyphen. These dashes should have a space before and after them. 96 97 **When to use hyphens?** 98 99 Hyphens are mostly commonly used as part of a “compound adjective”. For example, "jet-powered car". Note that the compound adjective must immediately precede the noun being modified. In other words, "jet powered" does not by itself need a hyphen. When in doubt, use Google, as compound adjectives are tricky and are a popular discussion on grammar discussion boards. 100 101 **How many spaces after a period?** 102 103 One. 104 105 **How should numbers be rendered?** 106 107 Number zero through nine are spelled out. One, two, three, four, etc. Numbers after 10 are rendered as numbers. 108 109 Exceptions to this would be usages from code. In that case, use whatever’s in the code. And also examples like Org1. Don’t write it as OrgOne. 110 111 **Capitalization rules for doc titles.** 112 113 The standard rules for capitalization in sentences should be followed. In other words, unless a word is the first word in the title or a proper noun, do not capitalize its first letter. For example, "Understanding Identities in Fabric" should be "Understanding identities in Fabric". While not every doc follows this standard yet, it is the standard we're moving to and should be followed for new topics. 114 115 Headings inside of topics should follow the same standard. 116 117 **Use the Oxford comma?** 118 119 Yes, it’s better. 120 121 The classic example is, “I’d like to thank my parents, Ayn Rand and God”, as compared to: “I’d like to thank my parents, Ayn Rand, and God.” 122 123 **Captions.** 124 125 These should be in italics, and it’s the only real valid use for italics in our docs. 126 127 **Commands.** 128 129 In general, put each command in its own snippet. It reads better, especially when commands are long. An exception to this rule is when suggesting the export of a number of environment variables. 130 131 **Code snippets.** 132 133 In Markdown, if you want to post sample code, use three back tics to set off the snippet. For example: 134 135 ``` 136 Code goes here. 137 138 Even more code goes here. 139 140 And still more. 141 ``` 142 143 In RST, you will need to set off the code snippet using formatting similar to this: 144 145 ``` 146 .. code:: bash 147 148 Code goes here. 149 ``` 150 151 You can substitute `bash` for a language like Java or Go, where appropriate. 152 153 **Enumerated lists in markdown.** 154 155 Note that in Markdown, enumerated lists will not work if you separate the numbers with a space. Markdown sees this as the start of a new list, not a continuation of the old one (every number will be `1.`). If you need an enumerated list, you will have to use RST. Bulleted lists are a good substitute in Markdown, and are the recommended alternative. 156 157 **Linking.** 158 159 When linking to another doc, use relative links, not direct links. When naming a link, do not just call it "link". Use a more creative and descriptive name. For accessibility reasons, the link name should also make it clear that it is a link. 160 161 **All docs have to end with a license statement.** 162 163 In RST, it’s this: 164 165 ``` 166 .. Licensed under Creative Commons Attribution 4.0 International License 167 https://creativecommons.org/licenses/by/4.0/ 168 ``` 169 170 In markdown: 171 172 ``` 173 <!--- Licensed under Creative Commons Attribution 4.0 International License 174 https://creativecommons.org/licenses/by/4.0/ --> 175 ``` 176 177 **How many spaces for indentation?** 178 179 This will depend on the use case. Frequently it’s necessary, especially in RST, to indent two spaces, especially in a code block. In a `.. note::` box in RST, you have to indent to the space after the colon after note, like this: 180 181 ``` 182 .. note:: Some words and stuff etc etc etc (line continues until the 70 character limit line) 183 the line directly below has to start at the same space as the one above. 184 ``` 185 186 **When to use which type of heading.** 187 188 In RST, use this: 189 190 ``` 191 Chapter 1 Title 192 =============== 193 194 Section 1.1 Title 195 ----------------- 196 197 Subsection 1.1.1 Title 198 ~~~~~~~~~~~~~~~~~~~~~~ 199 200 Section 1.2 Title 201 ----------------- 202 ``` 203 204 Note that the length of what’s under the title has to be the same as the length of the title itself. This isn’t a problem in Atom, which gives each character the same width by default (this is called “monospacing”, if you’re ever on Jeopardy! and need that information. 205 206 In markdown, it’s somewhat simpler. You go: 207 208 ``` 209 # The Name of the Doc (this will get pulled for the TOC). 210 211 ## First subsection 212 213 ## Second subsection 214 ``` 215 216 Both file formats don't like when these things are done out of order. For example, you might want a `####` to be the first thing after your `#` Title. Markdown won’t allow it. Similarly, RST will default to whatever order you give to the title formats (as they appear in the first sections of your doc). 217 218 **Relative links should be used whenever possible.** 219 220 For RST, the preferred syntax is: 221 ``` 222 :doc:`anchor text <relativepath>` 223 ``` 224 Do not put the .rst suffix at the end of the filepath. 225 226 For Markdown, the preferred syntax is: 227 ``` 228 [anchor text](<relativepath>) 229 ``` 230 231 For other files, such as text or YAML files, use a direct link to the file in 232 github for example: 233 234 [https://github.com/hechain20/hechain/blob/main/docs/README.md](https://github.com/hechain20/hechain/blob/main/docs/README.md) 235 236 Relative links are unfortunately not working on github when browsing through a 237 RST file. 238 239 <!--- Licensed under Creative Commons Attribution 4.0 International License 240 https://creativecommons.org/licenses/by/4.0/ -->