From d7e0d573e244601bc364cfbd5667d471fc5d18cd Mon Sep 17 00:00:00 2001 From: Able Date: Sun, 24 Nov 2024 11:57:06 -0600 Subject: [PATCH] Style guide commit. Feel free to bikeshed about it. What should be added etcetc --- STYLE_GUIDE.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 STYLE_GUIDE.md diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md new file mode 100644 index 00000000..63707b32 --- /dev/null +++ b/STYLE_GUIDE.md @@ -0,0 +1,47 @@ +# Style Guide +This style guide has two modes that a guideline may be. + +`strict` means that prs will be rejected if they do not follow the guideline. + +`loose` means that a pr would be accepted but should later be fixed. + + +## Magic Numbers | loose +The policy on magic numbers is make them const and have a comment above them. Typically linking to a source of information about the magic number. + +This helps cut down on magic numbers while making acceptable names and atleast half assed documentation. + +```rust +// The standard vga port is mapped at 0xB8000 +$VGA_PTR := 0xB8000 +``` + +## Tabs Vs Spaces | loose +I prefer for hblang code to use hard tabs. + +The rational behind this is that a tab is `1 Indent` which some developers might want to be various different sizes when displayed + +Soft tabs do not allow this user/editor specific as soft tabs always become spaces. + +Bottom line is this is an accessibility feature. + +There are some samples below. +``` +\t means hard tab +\n means new line +\0x20 means space +``` + +### Allowed +```rust +if x == y {\n +\tlog(z)\n +}\n +``` + +### Not Allowed +```rust +if x == y {\n +\0x20\0x20\0x20\0x20log(z)\n +}\n +``` \ No newline at end of file