contributing.html (4128B)
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 7 <link rel="stylesheet" href="style.css"> 8 <link rel="icon" type="image/png" href="favicon.png"> 9 <title>evenfri - contributing</title> 10 </head> 11 12 <body> 13 <div class="container"> 14 <h1><a href="index.html">evenfri</a></h1> 15 16 <div class="nav"> 17 < <a href="index.html">home</a> > 18 </div> 19 20 <h2>content</h2> 21 <ul> 22 <li><a href="#standards">coding standards</a></li> 23 <li><a href="#submit-patch">submitting patches</a></li> 24 </ul> 25 26 <h2 id="standards"><a href="#standards">coding standards</a></h2> 27 28 <h3>1. formatting & layout</h3> 29 <ul> 30 <li><strong>indentation:</strong> 2 spaces (no tabs)</li> 31 <li><strong>line length:</strong> max 80 characters</li> 32 <li><strong>whitespace:</strong> no trailing whitespace allowed</li> 33 <li><strong>brackets:</strong> K&R style (opening bracket on the same line)</li> 34 </ul> 35 36 <h3>2. naming conventions</h3> 37 <ul> 38 <li><strong>style:</strong> <code>snake_case</code> for functions, variables, and structures</li> 39 <li><strong>macros:</strong> <code>UPPER_CASE</code> for macros</li> 40 <li><strong>config macros:</strong> <code>CONFIG_UPPER_CASE</code> in <code>config.h</code> with prefix <code>CONFIG_</code></li> 41 <li><strong>pointers:</strong> <code>char* func(...)</code> for types, <code>const char *str</code> for variables</li> 42 </ul> 43 44 <h3>3. function design</h3> 45 <ul> 46 <li>keep functions small (50-75 lines max) and single-purpose</li> 47 <li>max 3 levels of nesting (split into helpers if deeper)</li> 48 </ul> 49 50 <h3>4. comments & headers</h3> 51 <ul> 52 <li>write in English, lowercase, no trailing dot (except copyright notices)</li> 53 <li>explain <em>why</em>, not <em>what</em></li> 54 <li>use standard C-style comments (<code>/* ... */</code>)</li> 55 <li>use include guards in lowercase for header files (e.g., <code><br> 56 #ifndef DIR_FILENAME_H<br> 57 #define DIR_FILENAME_H<br> 58 #endif /* DIR_FILENAME_H */</code>)</li> 59 <li>keep header files minimal: max 4 headers (<code>fns.h</code>, <code>dat.h</code>, project header, <code>config.h</code>)</li> 60 </ul> 61 62 <h3>5. dependencies & build</h3> 63 <ul> 64 <li><strong>dependencies:</strong> max 1-2 external dependencies; write custom code if non-essential</li> 65 <li><strong>allowed defaults:</strong> gcc, make, X11, libc, mk</li> 66 <li><strong>shell scripts:</strong> use <code>#!/bin/sh</code> and <code>snake_case</code> naming</li> 67 <li><strong>build tool:</strong> mkfile from <a href="http://git.evenfri.xyz/mk-standalone/log.html">repository</a></li> 68 <li><strong>languages:</strong> C, GASM, NASM</li> 69 </ul> 70 71 <h3>6. required files</h3> 72 <ul> 73 <li><code>README</code> and <code>LICENSE</code> in plain text format</li> 74 <li><code>mkfile</code></li> 75 </ul> 76 77 <h3>example</h3> 78 <pre>/* 79 * main.c — entry point example 80 */ 81 82 #define SYS_write 1 83 #define STDOUT 1 84 85 static long write(int fd, const void *buf, unsigned long count) { 86 long ret; 87 asm volatile ( 88 "syscall" 89 : "=a"(ret) 90 : "a"(SYS_write), "D"(fd), "S"(buf), "d"(count) 91 : "rcx", "r11", "memory" 92 ); 93 return ret; 94 } 95 96 int main(int argc, char *argv[]) { 97 write(STDOUT, "hello world\n", 12); 98 99 return 0; 100 }</pre> 101 102 <h2 id="submit-patch"><a href="#submit-patch">submitting patches</a></h2> 103 <ul> 104 <li><strong>committing changes:</strong> <code>git commit -m "feature: add lexer"</code></li> 105 <li><strong>generate patch:</strong> <code>git format-patch --subject-prefix="REPO-NAME PATCH" -1 HEAD</code></li> 106 <li><strong>send email:</strong> <code>git send-email --to="evenfri256@gmail.com" 0001-feature-add-lexer.patch</code></li> 107 </ul> 108 </div> 109 </body> 110 </html>