8000 GitHub - googol-lab/Nim at gh-pages · GitHub
[go: up one dir, main page]

Skip to content
googol-labPublic
forked from nim-lang/Nim

About

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).

Contributing

Stars

0 stars

Watchers

1 watching

Forks

 
 

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--  This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>

<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>

<!-- CSS -->
<title>Contributing</title>
<style type="text/css" >
/*
Stylesheet for use with Docutils/rst2html.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.

Modified from Chad Skeeters' rst2html-style
https://bitbucket.org/cskeeters/rst2html-style/

Modified by Boyd Greenfield and narimiran
*/

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%; }

body {
  font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: 1.125em;
  line-height: 1.5;
  color: #222;
  background-color: #FCFCFC; }

/* Skeleton grid */
.container {
  position: relative;
  width: 100%;
  max-width: 1050px;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box; }

.column,
.columns {
  width: 100%;
  float: left;
  box-sizing: border-box;
  margin-left: 1%;
}

.column:first-child,
.columns:first-child {
  margin-left: 0; }

.three.columns {
  width: 19%; }

.nine.columns {
  width: 80.0%; }

.twelve.columns {
  width: 100%;
  margin-left: 0; }

@media screen and (max-width: 860px) {
  .three.columns {
    display: none;
  }
  .nine.columns {
    width: 98.0%;
  }
  body {
    font-size: 1em;
    line-height: 1.35;
  }
}

cite {
  font-style: italic !important; }


/* Nim search input */
div#searchInputDiv {
  margin-bottom: 1em;
}
input#searchInput {
  width: 80%;
}


/* Docgen styles */
/* Links */
a {
  color: #07b;
  text-decoration: none;
}

a span.Identifier {
  text-decoration: underline;
  text-decoration-color: #aab;
}

a.reference-toplevel {
  font-weight: bold;
}

a.toc-backref {
  text-decoration: none;
  color: #222; }

a.link-seesrc {
  color: #607c9f;
  font-size: 0.9em;
  font-style: italic; }

a:hover,
a:focus {
  color: #607c9f;
  text-decoration: underline; }

a:hover span.Identifier {
  color: #607c9f;
}


sub,
sup {
  position: relative;
  font-size: 75%;
  line-height: 0;
  vertical-align: baseline; }

sup {
  top: -0.5em; }

sub {
  bottom: -0.25em; }

img {
  width: auto;
  height: auto;
  max-width: 100%;
  vertical-align: middle;
  border: 0;
  -ms-interpolation-mode: bicubic; }

@media print {
  * {
    color: black !important;
    text-shadow: none !important;
    background: transparent !important;
    box-shadow: none !important; }

  a,
  a:visited {
    text-decoration: underline; }

  a[href]:after {
    content: " (" attr(href) ")"; }

  abbr[title]:after {
    content: " (" attr(title) ")"; }

  .ir a:after,
  a[href^="javascript:"]:after,
  a[href^="#"]:after {
    content: ""; }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid; }

  thead {
    display: table-header-group; }

  tr,
  img {
    page-break-inside: avoid; }

  img {
    max-width: 100% !important; }

  @page {
    margin: 0.5cm; }

  h1 {
    page-break-before: always; }

  h1.title {
    page-break-before: avoid; }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3; }

  h2,
  h3 {
    page-break-after: avoid; }
}


p {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

small {
  font-size: 85%; }

strong {
  font-weight: 600;
  font-size: 0.95em;
  color: #3c3c3c;
}

em {
  font-style: italic; }

h1 {
  font-size: 1.8em;
  font-weight: 400;
  padding-bottom: .25em;
  border-bottom: 1px solid #aaa;
  margin-top: 2.5em;
  margin-bottom: 1em;
  line-height: 1.2em; }

h1.title {
  padding-bottom: 1em;
  border-bottom: 0px;
  font-size: 2.5em;
  text-align: center;
  font-weight: 900;
  margin-top: 0.75em;
  margin-bottom: 0em;
}

h2 {
  font-size: 1.3em;
  margin-top: 2em; }

h2.subtitle {
  text-align: center; }

h3 {
  font-size: 1.125em;
  font-style: italic;
  margin-top: 1.5em; }

h4 {
  font-size: 1.125em;
  margin-top: 1em; }

h5 {
  font-size: 1.125em;
  margin-top: 0.75em; }

h6 {
  font-size: 1.1em; }


ul,
ol {
  padding: 0;
  margin-top: 0.5em;
  margin-left: 0.75em; }

ul ul,
ul ol,
ol ol,
ol ul {
  margin-bottom: 0;
  margin-left: 1.25em; }

li {
    list-style-type: circle;
}

ul.simple-boot li {
    list-style-type: none;
    margin-left: 0em;
    margin-bottom: 0.5em;
}

ol.simple > li, ul.simple > li {
  margin-bottom: 0.25em;
  margin-left: 0.4em }

ul.simple.simple-toc > li {
    margin-top: 1em;
}

ul.simple-toc {
  list-style: none;
  font-size: 0.9em;
  margin-left: -0.3em;
  margin-top: 1em; }

ul.simple-toc > li {
    list-style-type: none;
}

ul.simple-toc-section {
  list-style-type: circle;
  margin-left: 1em;
  color: #6c9aae; }


ol.arabic {
  list-style: decimal; }

ol.loweralpha {
  list-style: lower-alpha; }

ol.upperalpha {
  list-style: upper-alpha; }

ol.lowerroman {
  list-style: lower-roman; }

ol.upperroman {
  list-style: upper-roman; }

ul.auto-toc {
  list-style-type: none; }


dl {
  margin-bottom: 1.5em; }

dt {
  margin-bottom: -0.5em;
  margin-left: 0.0em; }

dd {
  margin-left: 2.0em;
  margin-bottom: 3.0em;
  margin-top: 0.5em; }


hr {
  margin: 2em 0;
  border: 0;
  border-top: 1px solid #aaa; }

blockquote {
  font-size: 0.9em;
  font-style: italic;
  padding-left: 0.5em;
  margin-left: 0;
  border-left: 5px solid #bbc;
}

.pre {
  font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
  font-weight: 500;
  font-size: 0.85em;
  background-color: #f0f3ff;
  padding-left: 3px;
  padding-right: 3px;
  border-radius: 4px;
}

pre {
  font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
  color: #222;
  font-weight: 500;
  display: inline-block;
  box-sizing: border-box;
  min-width: 100%;
  padding: 0.5em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  font-size: 0.85em;
  white-space: pre !important;
  overflow-y: hidden;
  overflow-x: visible;
  background-color: ghostwhite;
  border: 1px solid #dde;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px; }

.pre-scrollable {
  max-height: 340px;
  overflow-y: scroll; }


/* Nim line-numbered tables */
.line-nums-table {
  width: 100%;
  table-layout: fixed; }

table.line-nums-table {
  border-radius: 4px;
  border: 1px solid #cccccc;
  background-color: ghostwhite;
  border-collapse: separate;
  margin-top: 15px;
  margin-bottom: 25px; }

.line-nums-table tbody {
  border: none; }

.line-nums-table td pre {
  border: none;
  background-color: transparent; }

.line-nums-table td.blob-line-nums {
  width: 28px; }

.line-nums-table td.blob-line-nums pre {
  color: #b0b0b0;
  -webkit-filter: opacity(75%);
  text-align: right;
  border-color: transparent;
  background-color: transparent;
  padding-left: 0px;
  margin-left: 0px;
  padding-right: 0px;
  margin-right: 0px; }


table {
  max-width: 100%;
  background-color: transparent;
  margin-top: 0.5em;
  margin-bottom: 1.5em;
  border-collapse: collapse;
  border-color: #ccc;
  border-spacing: 0;
  font-size: 0.9em;
}

table th, table td {
  padding: 0px 0.5em 0px;
}

table th {
  background-color: #e8e8e8;
  font-weight: bold; }

table th.docinfo-name {
    background-color: transparent;
}

table tr:hover {
  background-color: ghostwhite; }


/* rst2html default used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0; }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 !important; }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 !important; }

.last, .with-subtitle {
  margin-bottom: 0 !important; }

.hidden {
  display: none; }

blockquote.epigraph {
  margin: 2em 5em; }

dl.docutils dd {
  margin-bottom: 0.5em; }

object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
  overflow: hidden; }


div.figure {
  margin-left: 2em;
  margin-right: 2em; }

div.footer, div.header {
  clear: both;
  text-align: center;
  color: #666;
  font-size: smaller; }

div.footer {
    padding-top: 5em;
}

div.line-block {
  display: block;
  margin-top: 1em;
  margin-bottom: 1em; }

div.line-block div.line-block {
  margin-top: 0;
  margin-bottom: 0;
  margin-left: 1.5em; }

div.topic {
  margin: 2em; }

div.search_results {
  background-color: antiquewhite;
  margin: 3em;
  padding: 1em;
  border: 1px solid #4d4d4d;
}

div#global-links ul {
  margin-left: 0;
  list-style-type: none;
}

div#global-links > simple-boot {
    margin-left: 3em;
}

hr.docutils {
  width: 75%; }

img.align-left, .figure.align-left, object.align-left {
  clear: left;
  float: left;
  margin-right: 1em; }

img.align-right, .figure.align-right, object.align-right {
  clear: right;
  float: right;
  margin-left: 1em; }

img.align-center, .figure.align-center, object.align-center {
  display: block;
  margin-left: auto;
  margin-right: auto; }

.align-left {
  text-align: left; }

.align-center {
  clear: both;
  text-align: center; }

.align-right {
  text-align: right; }

/* reset inner alignment in figures */
div.align-right {
  text-align: inherit; }

p.attribution {
  text-align: right;
  margin-left: 50%; }

p.caption {
  font-style: italic; }

p.credits {
  font-style: italic;
  font-size: smaller; }

p.label {
  white-space: nowrap; }

p.rubric {
  font-weight: bold;
  font-size: larger;
  color: maroon;
  text-align: center; }

p.topic-title {
  font-weight: bold; }

pre.address {
  margin-bottom: 0;
  margin-top: 0;
  font: inherit; }

pre.literal-block, pre.doctest-block, pre.math, pre.code {
  margin-left: 2em;
  margin-right: 2em; }

pre.code .ln {
  color: grey; }

/* line numbers */
pre.code, code {
  background-color: #eeeeee; }

pre.code .comment, code .comment {
  color: #5c6576; }

pre.code .keyword, code .keyword {
  color: #3B0D06;
  font-weight: bold; }

pre.code .literal.string, code .literal.string {
  color: #0c5404; }

pre.code .name.builtin, code .name.builtin {
  color: #352b84; }

pre.code .deleted, code .deleted {
  background-color: #DEB0A1; }

pre.code .inserted, code .inserted {
  background-color: #A3D289; }

span.classifier {
  font-style: oblique; }

span.classifier-delimiter {
  font-weight: bold; }

span.option {
  white-space: nowrap; }

span.problematic {
  color: #b30000; }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80%; }

span.DecNumber {
  color: #252dbe; }

span.BinNumber {
  color: #252dbe; }

span.HexNumber {
  color: #252dbe; }

span.OctNumber {
  color: #252dbe; }

span.FloatNumber {
  color: #252dbe; }

span.Identifier {
  color: #222; }

span.Keyword {
  font-weight: 600;
  color: #5e8f60; }

span.StringLit {
  color: #a4255b; }

span.LongStringLit {
  color: #a4255b; }

span.CharLit {
  color: #a4255b; }

span.EscapeSequence {
  color: black; }

span.Operator {
  color: black; }

span.Punctuation {
  color: black; }

span.Comment, span.LongComment {
  font-style: italic;
  font-weight: 400;
  color: #484a86; }

span.RegularExpression {
  color: darkviolet; }

span.TagStart {
  color: darkviolet; }

span.TagEnd {
  color: darkviolet; }

span.Key {
  color: #252dbe; }

span.Value {
  color: #252dbe; }

span.RawData {
  color: #a4255b; }

span.Assembler {
  color: #252dbe; }

span.Preprocessor {
  color: #252dbe; }

span.Directive {
  color: #252dbe; }

span.Command, span.Rule, span.Hyperlink, span.Label, span.Reference,
span.Other {
  color: black; }

/* Pop type, const, proc, and iterator defs in nim def blocks */
dt pre > span.Identifier, dt pre > span.Operator {
  color: #155da4;
  font-weight: 700; }

dt pre > span.Keyword ~ span.Identifier, dt pre > span.Identifier ~ span.Identifier,
dt pre > span.Operator ~ span.Identifier, dt pre > span.Other ~ span.Identifier {
  color: inherit;
  font-weight: inherit; }

/* Nim sprite for the footer (taken from main page favicon) */
.nim-sprite {
  display: inline-block;
  height: 16px;
  width: 16px;
  background-position: 0 0;
  background-size: 16px 16px;
  -webkit-filter: opacity(50%);
  background-repeat: no-repeat;
  background-image: url("data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA==");
  margin-bottom: -5px; }

span.pragmadots {
  /* Position: relative frees us up to make the dots
  look really nice without fucking up the layout and
  causing bulging in the parent container */
  position: relative;
  /* 1px down looks slightly nicer */
  top: 1px;
  padding: 2px;
  background-color: #e8e8e8;
  border-radius: 4px;
  margin: 0 2px;
  cursor: pointer;
  font-size: 0.8em;
}

span.pragmadots:hover {
  background-color: #DBDBDB;
}
span.pragmawrap {
  display: none;
}

span.attachedType {
  display: none;
  visibility: hidden;
}
</style>

<script type="text/javascript" src="dochack.js"></script>

<script type="text/javascript">
function main() {
  var pragmaDots = document.getElementsByClassName("pragmadots");
  for (var i = 0; i < pragmaDots.length; i++) {
    pragmaDots[i]. {
      // Hide tease
      event.target.parentNode.style.display = "none";
      // Show actual
      event.target.parentNode.nextElementSibling.style.display = "inline";
    }
  }
}
</script>

</head>
<body >
<div class="document" id="documentId">
  <div class="container">
    <h1 class="title">Contributing</h1>
    <div class="row">
  <div class="three columns">
  <div id="global-links">
    <ul class="simple-boot">
      <li>
        <a href="manual.html">Manual</a>
      </li>
      <li>
        <a href="lib.html">Standard library</a>
      </li>
      <li>
        <a href="theindex.html">Index</a>
      </li>
    </ul>
  </div>
  <div id="searchInputDiv">
    Search: <input type="text" id="searchInput"
       />
  </div>
  <ul class="simple simple-toc" id="toc-list">
<li><a class="reference" id="writing-tests_toc" href="#writing-tests">Writing tests</a></li>
<ul class="simple"><li><a class="reference" id="writing-tests-stdlib_toc" href="#writing-tests-stdlib">Stdlib</a></li>
<li><a class="reference" id="writing-tests-compiler_toc" href="#writing-tests-compiler">Compiler</a></li>
</ul><li><a class="reference" id="running-tests_toc" href="#running-tests">Running tests</a></li>
<li><a class="reference" id="comparing-tests_toc" href="#comparing-tests">Comparing tests</a></li>
<li><a class="reference" id="deprecation_toc" href="#deprecation">Deprecation</a></li>
<li><a class="reference" id="documentation_toc" href="#documentation">Documentation</a></li>
<li><a class="reference" id="best-practices_toc" href="#best-practices">Best practices</a></li>
<li><a class="reference" id="the-git-stuff_toc" href="#the-git-stuff">The Git stuff</a></li>
<ul class="simple"><li><a class="reference" id="the-git-stuff-general-commit-rules_toc" href="#the-git-stuff-general-commit-rules">General commit rules</a></li>
<li><a class="reference" id="the-git-stuff-continuous-integration-ci_toc" href="#the-git-stuff-continuous-integration-ci">Continuous Integration (CI)</a></li>
<li><a class="reference" id="the-git-stuff-code-reviews_toc" href="#the-git-stuff-code-reviews">Code reviews</a></li>
</ul><li><a class="reference" id="documentation-style_toc" href="#documentation-style">Documentation Style</a></li>
<ul class="simple"><li><a class="reference" id="documentation-style-general-guidelines_toc" href="#documentation-style-general-guidelines">General Guidelines</a></li>
<li><a class="reference" id="documentation-style-moduleminuslevel-documentation_toc" href="#documentation-style-moduleminuslevel-documentation">Module-level documentation</a></li>
<li><a class="reference" id="documentation-style-procs-templates-macros-converters-and-iterators_toc" href="#documentation-style-procs-templates-macros-converters-and-iterators">Procs, Templates, Macros, Converters, and Iterators</a></li>
<li><a class="reference" id="documentation-style-types_toc" href="#documentation-style-types">Types</a></li>
<li><a class="reference" id="documentation-style-var-let-and-const_toc" href="#documentation-style-var-let-and-const">Var, Let, and Const</a></li>
</ul>
</ul>

  </div>
  <div class="nine columns" id="content">
  <div id="tocRoot"></div>
  <p class="module-desc"><p>Contributing happens via &quot;Pull requests&quot; (PR) on github. Every PR needs to be reviewed before it can be merged and the Continuous Integration should be green.</p>
<p>The PR has to be approved (and is often merged too) by one &quot;code owner&quot;, either by the code owner who is responsible for the subsystem the PR belongs to or by two core developers or by Araq.</p>
<p>See <a class="reference external" href="codeowners.html">codeowners</a> for more details.</p>

<h1><a class="toc-backref" id="writing-tests" href="#writing-tests">Writing tests</a></h1><p>There are 3 types of tests:</p>
<ol class="simple"><li><tt class="docutils literal"><span class="pre">runnableExamples</span></tt> documentation comment tests, ran by <tt class="docutils literal"><span class="pre">nim doc mymod.nim</span></tt> These end up in documentation and ensure documentation stays in sync with code.</li>
<li>tests in <tt class="docutils literal"><span class="pre">when isMainModule:</span></tt> block, ran by <tt class="docutils literal"><span class="pre">nim c mymod.nim</span></tt> <tt class="docutils literal"><span class="pre">nimble test</span></tt> also typially runs these in external nimble packages.</li>
<li>testament tests, eg: <tt class="docutils literal"><span class="pre">tests/stdlib/tos.nim</span></tt> (only used for Nim repo).</li>
</ol>
<p>Not all the tests follow the convention here, feel free to change the ones that don't. Always leave the code cleaner than you found it.</p>

<h2><a class="toc-backref" id="writing-tests-stdlib" href="#writing-tests-stdlib">Stdlib</a></h2><p>If you change the stdlib (anything under <tt class="docutils literal"><span class="pre">lib/</span></tt>, eg <tt class="docutils literal"><span class="pre">lib/pure/os.nim</span></tt>), put a test in the file you changed. Add the tests under a <tt class="docutils literal"><span class="pre">when isMainModule:</span></tt> condition so they only get executed when the tester is building the file. Each test should be in a separate <tt class="docutils literal"><span class="pre">block:</span></tt> statement, such that each has its own scope. Use boolean conditions and <tt class="docutils literal"><span class="pre">doAssert</span></tt> for the testing by itself, don't rely on echo statements or similar.</p>
<p>Sample test:</p>
<pre class="listing"><span class="Keyword">when</span> <span class="Identifier">isMainModule</span><span class="Punctuation">:</span>
  <span class="Keyword">block</span><span class="Punctuation">:</span> <span class="Comment"># newSeqWith tests</span>
    <span class="Keyword">var</span> <span class="Identifier">seq2D</span> <span class="Operator">=</span> <span class="Identifier">newSeqWith</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">newSeq</span><span class="Punctuation">[</span><span class="Identifier">bool</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
    <span class="Identifier">seq2D</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Identifier">true</span>
    <span class="Identifier">seq2D</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">]</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Identifier">true</span>
    <span class="Identifier">seq2D</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Identifier">true</span>
    <span class="Identifier">doAssert</span> <span class="Identifier">seq2D</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">true</span><span class="Punctuation">,</span> <span class="Identifier">true</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">true</span><span class="Punctuation">,</span> <span class="Identifier">false</span><span class="Punctuation">]</span><span class="Punctuation">,</span>
                        <span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">false</span><span class="Punctuation">,</span> <span class="Identifier">false</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">false</span><span class="Punctuation">,</span> <span class="Identifier">false</span><span class="Punctuation">]</span><span class="Punctuation">]</span>
    <span class="Comment"># doAssert with `not` can now be done as follows:</span>
    <span class="Identifier">doAssert</span> <span class="Keyword">not</span> <span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">==</span> <span class="DecNumber">2</span><span class="Punctuation">)</span></pre><p>Newer tests tend to be run via <tt class="docutils literal"><span class="pre">testament</span></tt> rather than via <tt class="docutils literal"><span class="pre">when isMainModule:</span></tt>, eg <tt class="docutils literal"><span class="pre">tests/stdlib/tos.nim</span></tt>; this allows additional features such as custom compiler flags; for more details see below.</p>

<h2><a class="toc-backref" id="writing-tests-compiler" href="#writing-tests-compiler">Compiler</a></h2><p>The tests for the compiler use a testing tool called <tt class="docutils literal"><span class="pre">testament</span></tt>. They are all located in <tt class="docutils literal"><span class="pre">tests/</span></tt> (e.g.: <tt class="docutils literal"><span class="pre">tests/destructor/tdestructor3.nim</span></tt>). Each test has its own file. All test files are prefixed with <tt class="docutils literal"><span class="pre">t</span></tt>. If you want to create a file for import into another test only, use the prefix <tt class="docutils literal"><span class="pre">m</span></tt>.</p>
<p>At the beginning of every test is the expected behavior of the test. Possible keys are:</p>
<ul class="simple"><li><tt class="docutils literal"><span class="pre">cmd</span></tt>: A compilation command template e.g. <tt class="docutils literal"><span class="pre">nim $target --threads:on $options $file</span></tt></li>
<li><tt class="docutils literal"><span class="pre">output</span></tt>: The expected output (stdout + stderr), most likely via <tt class="docutils literal"><span class="pre">echo</span></tt></li>
<li><tt class="docutils literal"><span class="pre">exitcode</span></tt>: Exit code of the test (via <tt class="docutils literal"><span class="pre">exit(number)</span></tt>)</li>
<li><tt class="docutils literal"><span class="pre">errormsg</span></tt>: The expected compiler error message</li>
<li><tt class="docutils literal"><span class="pre">file</span></tt>: The file the errormsg was produced at</li>
<li><tt class="docutils literal"><span class="pre">line</span></tt>: The line the errormsg was produced at</li>
</ul>
<p>For a full spec, see here: <tt class="docutils literal"><span class="pre">testament/specs.nim</span></tt></p>
<p>An example for a test:</p>
<pre class="listing"><span class="Keyword">discard</span> <span class="LongStringLit">&quot;&quot;&quot;
  errormsg: &quot;type mismatch: got (PTest)&quot;
&quot;&quot;&quot;</span>

<span class="Keyword">type</span>
  <span class="Identifier">PTest</span> <span class="Operator">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>

<span class="Keyword">proc</span> <span class="Identifier">test</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">PTest</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span> <span class="Operator">=</span> <span class="Keyword">nil</span>

<span class="Keyword">var</span> <span class="Identifier">buf</span><span class="Punctuation">:</span> <span class="Identifier">PTest</span>
<span class="Identifier">buf</span><span class="Operator">.</span><span class="Identifier">test</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre>
<h1><a class="toc-backref" id="running-tests" href="#running-tests">Running tests</a></h1><p>You can run the tests with</p>
<pre>
./koch tests</pre>
<p>which will run a good subset of tests. Some tests may fail. If you only want to see the output of failing tests, go for</p>
<pre>
./koch tests --failing all</pre>
<p>You can also run only a single category of tests. A category is a subdirectory in the <tt class="docutils literal"><span class="pre">tests</span></tt> directory. There are a couple of special categories; for a list of these, see <tt class="docutils literal"><span class="pre">testament/categories.nim</span></tt>, at the bottom.</p>
<pre>
./koch tests c lib # compiles/runs stdlib modules, including `isMainModule` tests
./koch tests c megatest # runs a set of tests that can be combined into 1</pre>
<p>To run a single test:</p>
<pre>
./koch test run &lt;category&gt;/&lt;name&gt;    # eg: tuples/ttuples_issues
./koch test run tests/stdlib/tos.nim # can also provide relative path</pre>
<p>For reproducible tests (to reproduce an environment more similar to the one run by Continuous Integration on travis/appveyor), you may want to disable your local configuration (eg in <tt class="docutils literal"><span class="pre">~/.config/nim/nim.cfg</span></tt>) which may affect some tests; this can also be achieved by using <tt class="docutils literal"><span class="pre">export XDG_CONFIG_HOME=pathtoAlternateConfig</span></tt> before running <tt class="docutils literal"><span class="pre">./koch</span></tt> commands.</p>

<h1><a class="toc-backref" id="comparing-tests" href="#comparing-tests">Comparing tests</a></h1><p>Because some tests fail in the current <tt class="docutils literal"><span class="pre">devel</span></tt> branch, not every failure after your change is necessarily caused by your changes. Some tests are flaky and will fail on occasion; these are typically bugs that should be fixed. Test failures can be grepped using <tt class="docutils literal"><span class="pre">Failure:</span></tt>.</p>
<p>The tester can compare two test runs. First, you need to create the reference test. You'll also need to the commit id, because that's what the tester needs to know in order to compare the two.</p>
<pre>
git checkout devel
DEVEL_COMMIT=$(git rev-parse HEAD)
./koch tests</pre>
<p>Then switch over to your changes and run the tester again.</p>
<pre>
git checkout your-changes
./koch tests</pre>
<p>Then you can ask the tester to create a <tt class="docutils literal"><span class="pre">testresults.html</span></tt> which will tell you if any new tests passed/failed.</p>
<pre>
./koch tests --print html $DEVEL_COMMIT</pre>

<h1><a class="toc-backref" id="deprecation" href="#deprecation">Deprecation</a></h1><p>Backward compatibility is important, so instead of a rename you need to deprecate the old name and introduce a new name:</p>
<pre class="listing"><span class="Comment"># for routines (proc/template/macro/iterator) and types:</span>
<span class="Keyword">proc</span> <span class="Identifier">oldProc</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">deprecated</span><span class="Punctuation">:</span> <span class="StringLit">&quot;use `newImpl: string -&gt; int` instead&quot;</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span> <span class="Keyword">discard</span>

<span class="Comment"># for (const/var/let/fields) the msg is not yet supported:</span>
<span class="Keyword">const</span> <span class="Identifier">Foo</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">deprecated</span><span class="Operator">.</span><span class="Punctuation">}</span>  <span class="Operator">=</span> <span class="DecNumber">1</span>

<span class="Comment"># for enum types, you can deprecate the type or some elements</span>
<span class="Comment"># (likewise with object types and their fields):</span>
<span class="Keyword">type</span> <span class="Identifier">Bar</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">deprecated</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span> <span class="Keyword">enum</span> <span class="Identifier">bar0</span><span class="Punctuation">,</span> <span class="Identifier">bar1</span>
<span class="Keyword">type</span> <span class="Identifier">Barz</span>  <span class="Operator">=</span> <span class="Keyword">enum</span> <span class="Identifier">baz0</span><span class="Punctuation">,</span> <span class="Identifier">baz1</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">deprecated</span><span class="Operator">.</span><span class="Punctuation">}</span><span class="Punctuation">,</span> <span class="Identifier">baz2</span></pre><p>See also <a class="reference external" href="https://nim-lang.org/docs/manual.html#pragmas-deprecated-pragma">Deprecated</a> pragma in the manual.</p>

<h1><a class="toc-backref" id="documentation" href="#documentation">Documentation</a></h1><p>When contributing new procs, be sure to add documentation, especially if the proc is public. Even private procs benefit from documentation and can be viewed using <tt class="docutils literal"><span class="pre">nim doc --docInternal foo.nim</span></tt>. Documentation begins on the line following the <tt class="docutils literal"><span class="pre">proc</span></tt> definition, and is prefixed by <tt class="docutils literal"><span class="pre">##</span></tt> on each line.</p>
<p>Runnable code examples are also encouraged, to show typical behavior with a few test cases (typically 1 to 3 <tt class="docutils literal"><span class="pre">assert</span></tt> statements, depending on complexity). These <tt class="docutils literal"><span class="pre">runnableExamples</span></tt> are automatically run by <tt class="docutils literal"><span class="pre">nim doc mymodule.nim</span></tt> as well as <tt class="docutils literal"><span class="pre">testament</span></tt> and guarantee they stay in sync.</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">addBar</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">string</span> <span class="Operator">=</span>
  <span class="Comment">## Adds &quot;Bar&quot; to `a`.</span>
  <span class="Identifier">runnableExamples</span><span class="Punctuation">:</span>
    <span class="Identifier">assert</span> <span class="StringLit">&quot;baz&quot;</span><span class="Operator">.</span><span class="Identifier">addBar</span> <span class="Operator">==</span> <span class="StringLit">&quot;bazBar&quot;</span>
  <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">a</span> <span class="Operator">&amp;</span> <span class="StringLit">&quot;Bar&quot;</span></pre><p>See <a class="reference external" href="https://nim-lang.github.io/Nim/os.html#parentDir%2Cstring">parentDir</a> example.</p>
<p>The RestructuredText Nim uses has a special syntax for including code snippets embedded in documentation; these are not run by <tt class="docutils literal"><span class="pre">nim doc</span></tt> and therefore are not guaranteed to stay in sync, so <tt class="docutils literal"><span class="pre">runnableExamples</span></tt> is usually preferred:</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">someproc</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">string</span> <span class="Operator">=</span>
  <span class="Comment">## Return &quot;something&quot;</span>
  <span class="Comment">##</span>
  <span class="Comment">## .. code-block::</span>
  <span class="Comment">##  echo someproc() # &quot;something&quot;</span>
  <span class="Identifier">result</span> <span class="Operator">=</span> <span class="StringLit">&quot;something&quot;</span> <span class="Comment"># single-hash comments do not produce documentation</span></pre><p>The <tt class="docutils literal"><span class="pre">.. code-block:: nim</span></tt> followed by a newline and an indentation instructs the <tt class="docutils literal"><span class="pre">nim doc</span></tt> command to produce syntax-highlighted example code with the documentation (<tt class="docutils literal"><span class="pre">.. code-block::</span></tt> is sufficient from inside a nim module).</p>
<p>When forward declaration is used, the documentation should be included with the first appearance of the proc.</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">hello</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  <span class="Comment">## Put documentation here</span>
<span class="Keyword">proc</span> <span class="Identifier">nothing</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span> <span class="Keyword">discard</span>
<span class="Keyword">proc</span> <span class="Identifier">hello</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">string</span> <span class="Operator">=</span>
  <span class="Comment">## ignore this</span>
  <span class="Identifier">echo</span> <span class="StringLit">&quot;hello&quot;</span></pre><p>The preferred documentation style is to begin with a capital letter and use the imperative (command) form. That is, between:</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">hello</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">string</span> <span class="Operator">=</span>
  <span class="Comment">## Return &quot;hello&quot;</span>
  <span class="Identifier">result</span> <span class="Operator">=</span> <span class="StringLit">&quot;hello&quot;</span></pre><p>or</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">hello</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">string</span> <span class="Operator">=</span>
  <span class="Comment">## says hello</span>
  <span class="Identifier">result</span> <span class="Operator">=</span> <span class="StringLit">&quot;hello&quot;</span></pre><p>the first is preferred.</p>

<h1><a class="toc-backref" id="best-practices" href="#best-practices">Best practices</a></h1><p>Note: these are general guidelines, not hard rules; there are always exceptions. Code reviews can just point to a specific section here to save time and propagate best practices.</p>
<p>Take advantage of no implicit bool conversion</p>
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">isValid</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
<span class="Identifier">doAssert</span> <span class="Identifier">isValid</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># preferred</span></pre><p>Design with method call syntax chaining in mind</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Identifier">cond</span><span class="Punctuation">:</span> <span class="Identifier">bool</span><span class="Punctuation">,</span> <span class="Identifier">lines</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Comment"># bad</span>
<span class="Keyword">proc</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Identifier">lines</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">cond</span><span class="Punctuation">:</span> <span class="Identifier">bool</span><span class="Punctuation">)</span> <span class="Comment"># preferred</span>
<span class="Comment"># can be called as: `getLines().foo(false)`</span></pre><p>Use exceptions (including assert / doAssert) instead of <tt class="docutils literal"><span class="pre">quit</span></tt> rationale: <a class="reference external" href="https://forum.nim-lang.org/t/4089">https://forum.nim-lang.org/t/4089</a></p>
<pre class="listing"><span class="Identifier">quit</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># bad in almost all cases</span>
<span class="Identifier">doAssert</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># preferred</span></pre><p>Use <tt class="docutils literal"><span class="pre">doAssert</span></tt> (or <tt class="docutils literal"><span class="pre">require</span></tt>, etc), not <tt class="docutils literal"><span class="pre">assert</span></tt> in all tests so they'll be enabled even in release mode (except for tests in <tt class="docutils literal"><span class="pre">runnableExamples</span></tt> blocks which for which <tt class="docutils literal"><span class="pre">nim doc</span></tt> ignores <tt class="docutils literal"><span class="pre">-d:release</span></tt>).</p>
<pre class="listing"><span class="Keyword">when</span> <span class="Identifier">isMainModule</span><span class="Punctuation">:</span>
  <span class="Identifier">assert</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># bad</span>
  <span class="Identifier">doAssert</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># preferred</span></pre><p>Delegate printing to caller: return <tt class="docutils literal"><span class="pre">string</span></tt> instead of calling <tt class="docutils literal"><span class="pre">echo</span></tt> rationale: it's more flexible (eg allows caller to call custom printing, including prepending location info, writing to log files, etc).</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span> <span class="Identifier">echo</span> <span class="StringLit">&quot;bar&quot;</span> <span class="Comment"># bad</span>
<span class="Keyword">proc</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">string</span> <span class="Operator">=</span> <span class="StringLit">&quot;bar&quot;</span> <span class="Comment"># preferred (usually)</span></pre><p>[Ongoing debate] Consider using Option instead of return bool + var argument, unless stack allocation is needed (eg for efficiency).</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Keyword">var</span> <span class="Identifier">Bar</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">bool</span>
<span class="Keyword">proc</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Option</span><span class="Punctuation">[</span><span class="Identifier">Bar</span><span class="Punctuation">]</span></pre><p>Tests (including in testament) should always prefer assertions over <tt class="docutils literal"><span class="pre">echo</span></tt>, except when that's not possible. It's more precise, easier for readers and maintaners to where expected values refer to. See for example <a class="reference external" href="https://github.com/nim-lang/Nim/pull/9335">https://github.com/nim-lang/Nim/pull/9335</a> and <a class="reference external" href="https://forum.nim-lang.org/t/4089">https://forum.nim-lang.org/t/4089</a></p>
<pre class="listing"><span class="Identifier">echo</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Comment"># adds a line for testament in `output:` block inside `discard`.</span>
<span class="Identifier">doAssert</span> <span class="Identifier">foo</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">]</span> <span class="Comment"># preferred, except when not possible to do so.</span></pre>
<h1><a class="toc-backref" id="the-git-stuff" href="#the-git-stuff">The Git stuff</a></h1>
<h2><a class="toc-backref" id="the-git-stuff-general-c
B368
ommit-rules" href="#the-git-stuff-general-commit-rules">General commit rules</a></h2><ol class="simple"><li>Bugfixes that should be backported to the latest stable release should contain the string <tt class="docutils literal"><span class="pre">[backport]</span></tt> in the commit message! There will be an outmated process relying on these. However, bugfixes also have the inherent risk of causing regressions which are worse for a &quot;stable, bugfixes-only&quot; branch, so in doubt, leave out the <tt class="docutils literal"><span class="pre">[backport]</span></tt>. Standard library bugfixes are less critical than compiler bugfixes.</li>
<li><p>All changes introduced by the commit (diff lines) must be related to the subject of the commit.</p>
<p>If you change something unrelated to the subject parts of the file, because your editor reformatted automatically the code or whatever different reason, this should be excluded from the commit.</p>
<p><em>Tip:</em> Never commit everything as is using <tt class="docutils literal"><span class="pre">git commit -a</span></tt>, but review carefully your changes with <tt class="docutils literal"><span class="pre">git add -p</span></tt>.</p>
</li>
<li><p>Changes should not introduce any trailing whitespace.</p>
<p>Always check your changes for whitespace errors using <tt class="docutils literal"><span class="pre">git diff --check</span></tt> or add following <tt class="docutils literal"><span class="pre">pre-commit</span></tt> hook:</p>
<pre class="listing">
#!/bin/sh
git diff --check --cached || exit $?</pre></li>
</ol>
<p>4. Describe your commit and use your common sense.</p>
<blockquote><p><p>Example Commit messages: <tt class="docutils literal"><span class="pre">Fixes #123; refs #124</span></tt></p>
<p>indicates that issue <tt class="docutils literal"><span class="pre">#123</span></tt> is completely fixed (github may automatically close it when the PR is committed), wheres issue <tt class="docutils literal"><span class="pre">#124</span></tt> is referenced (eg: partially fixed) and won't close the issue when committed.</p>
</p></blockquote>
<ol class="simple"><li><p>Commits should be always be rebased against devel (so a fast forward merge can happen)</p>
<p>eg: use <tt class="docutils literal"><span class="pre">git pull --rebase origin devel</span></tt>. This is to avoid messing up git history, see <a class="reference external" href="https://github.com/nim-lang/Nim/issues/8664">#8664</a> . Exceptions should be very rare: when rebase gives too many conflicts, simply squash all commits using the script shown in <a class="reference external" href="https://github.com/nim-lang/Nim/pull/9356">https://github.com/nim-lang/Nim/pull/9356</a></p>
</li>
</ol>
<ol class="simple"><li>Do not mix pure formatting changes (eg whitespace changes, nimpretty) or automated changes (eg nimfix) with other code changes: these should be in separate commits (and the merge on github should not squash these into 1).</li>
</ol>

<h2><a class="toc-backref" id="the-git-stuff-continuous-integration-ci" href="#the-git-stuff-continuous-integration-ci">Continuous Integration (CI)</a></h2><ol class="simple"><li>Continuous Integration is by default run on every push in a PR; this clogs the CI pipeline and affects other PR's; if you don't need it (eg for WIP or documentation only changes), add <tt class="docutils literal"><span class="pre">[ci skip]</span></tt> to your commit message title. This convention is supported by <a class="reference external" href="https://www.appveyor.com/docs/how-to/filtering-commits/#skip-directive-in-commit-message">Appveyor</a> and <a class="reference external" href="https://docs.travis-ci.com/user/customizing-the-build/#skipping-a-build">Travis</a></li>
</ol>
<ol class="simple"><li>Consider enabling CI (travis and appveyor) in your own Nim fork, and waiting for CI to be green in that fork (fixing bugs as needed) before opening your PR in original Nim repo, so as to reduce CI congestion. Same applies for updates on a PR: you can test commits on a separate private branch before updating the main PR.</li>
</ol>

<h2><a class="toc-backref" id="the-git-stuff-code-reviews" href="#the-git-stuff-code-reviews">Code reviews</a></h2><ol class="simple"><li>Whenever possible, use github's new 'Suggested change' in code reviews, which saves time explaining the change or applying it; see also <a class="reference external" href="https://forum.nim-lang.org/t/4317">https://forum.nim-lang.org/t/4317</a></li>
<li>When reviewing large diffs that may involve code moving around, github's interface doesn't help much as it doesn't highlight moves. Instead you can use something like this, see visual results <a class="reference external" href="https://github.com/nim-lang/Nim/pull/10431#issuecomment-456968196">here</a>:<pre class="listing">
git fetch origin pull/10431/head &amp;&amp; git checkout FETCH_HEAD
git show --color-moved-ws=allow-indentation-change --color-moved=blocks HEAD^</pre></li>
</ol>
<ol class="simple"><li>In addition, you can view github-like diffs locally to identify what was changed within a code block using <tt class="docutils literal"><span class="pre">diff-highlight</span></tt> or <tt class="docutils literal"><span class="pre">diff-so-fancy</span></tt>, eg:<pre class="listing">
# put this in ~/.gitconfig:
[core]
  pager = &quot;diff-so-fancy | less -R&quot; # or: use: `diff-highlight`</pre></li>
</ol>

<h1><a class="toc-backref" id="documentation-style" href="#documentation-style">Documentation Style</a></h1>
<h2><a class="toc-backref" id="documentation-style-general-guidelines" href="#documentation-style-general-guidelines">General Guidelines</a></h2><ul class="simple"><li>Authors should document anything that is exported; documentation for private procs can be useful too (visible via <tt class="docutils literal"><span class="pre">nim doc --docInternal foo.nim</span></tt>).</li>
<li>Within documentation, a period (<tt class="docutils literal"><span class="pre">.</span></tt>) should follow each sentence (or sentence fragment) in a comment block. The documentation may be limited to one sentence fragment, but if multiple sentences are within the documentation, each sentence after the first should be complete and in present tense.</li>
<li>Documentation is parsed as a custom ReStructuredText (RST) with partial markdown support.</li>
</ul>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">someproc</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Identifier">s</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">,</span> <span class="Identifier">foo</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  <span class="Comment">## Use single backticks for inline code, eg: `s` or `someExpr(true)`.</span>
  <span class="Comment">## Use a backlash to follow with alphanumeric char: `int8`\s are great.</span></pre>
<h2><a class="toc-backref" id="documentation-style-moduleminuslevel-documentation" href="#documentation-style-moduleminuslevel-documentation">Module-level documentation</a></h2><p>Documentation of a module is placed at the top of the module itself. Each line of documentation begins with double hashes (<tt class="docutils literal"><span class="pre">##</span></tt>). Sometimes <tt class="docutils literal"><span class="pre">##[ multiline docs containing code ]##</span></tt> is preferable, see <tt class="docutils literal"><span class="pre">lib/pure/times.nim</span></tt>. Code samples are encouraged, and should follow the general RST syntax:</p>
<pre class="listing"><span class="Comment">## The `universe` module computes the answer to life, the universe, and everything.</span>
<span class="Comment">##</span>
<span class="Comment">## .. code-block::</span>
<span class="Comment">##  doAssert computeAnswerString() == 42</span></pre><p>Within this top-level comment, you can indicate the authorship and copyright of the code, which will be featured in the produced documentation.</p>
<pre class="listing"><span class="Comment">## This is the best module ever. It provides answers to everything!</span>
<span class="Comment">##</span>
<span class="Comment">## :Author: Steve McQueen</span>
<span class="Comment">## :Copyright: 1965</span>
<span class="Comment">##</span></pre><p>Leave a space between the last line of top-level documentation and the beginning of Nim code (the imports, etc.).</p>

<h2><a class="toc-backref" id="documentation-style-procs-templates-macros-converters-and-iterators" href="#documentation-style-procs-templates-macros-converters-and-iterators">Procs, Templates, Macros, Converters, and Iterators</a></h2><p>The documentation of a procedure should begin with a capital letter and should be in present tense. Variables referenced in the documentation should be surrounded by single tick marks:</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">example1</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span> <span class="Operator">=</span>
  <span class="Comment">## Prints the value of `x`.</span>
  <span class="Identifier">echo</span> <span class="Identifier">x</span></pre><p>Whenever an example of usage would be helpful to the user, you should include one within the documentation in RST format as below.</p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">addThree</span><span class="Operator">*</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">,</span> <span class="Identifier">z</span><span class="Punctuation">:</span> <span class="Identifier">int8</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">int</span> <span class="Operator">=</span>
  <span class="Comment">## Adds three `int8` values, treating them as unsigned and</span>
  <span class="Comment">## truncating the result.</span>
  <span class="Comment">##</span>
  <span class="Comment">## .. code-block::</span>
  <span class="Comment">##  # things that aren't suitable for a `runnableExamples` go in code-block:</span>
  <span class="Comment">##  echo execCmdEx(&quot;git pull&quot;)</span>
  <span class="Comment">##  drawOnScreen()</span>
  <span class="Identifier">runnableExamples</span><span class="Punctuation">:</span>
    <span class="Comment"># `runnableExamples` is usually preferred to `code-block`, when possible.</span>
    <span class="Identifier">doAssert</span> <span class="Identifier">addThree</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">125</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">122</span>
  <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">x</span> <span class="Operator">+%</span> <span class="Identifier">y</span> <span class="Operator">+%</span> <span class="Identifier">z</span></pre><p>The commands <tt class="docutils literal"><span class="pre">nim doc</span></tt> and <tt class="docutils literal"><span class="pre">nim doc2</span></tt> will then correctly syntax highlight the Nim code within the documentation.</p>

<h2><a class="toc-backref" id="documentation-style-types" href="#documentation-style-types">Types</a></h2><p>Exported types should also be documented. This documentation can also contain code samples, but those are better placed with the functions to which they refer.</p>
<pre class="listing"><span class="Keyword">type</span>
  <span class="Identifier">NamedQueue</span><span class="Operator">*</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Keyword">object</span> <span class="Comment">## Provides a linked data structure with names</span>
                          <span class="Comment">## throughout. It is named for convenience. I'm making</span>
                          <span class="Comment">## this comment long to show how you can, too.</span>
    <span class="Identifier">name</span><span class="Operator">*:</span> <span class="Identifier">string</span> <span class="Comment">## The name of the item</span>
    <span class="Identifier">val</span><span class="Operator">*:</span> <span class="Identifier">T</span> <span class="Comment">## Its value</span>
    <span class="Identifier">next</span><span class="Operator">*:</span> <span class="Keyword">ref</span> <span class="Identifier">NamedQueue</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Comment">## The next item in the queue</span></pre><p>You have some flexibility when placing the documentation:</p>
<pre class="listing"><span class="Keyword">type</span>
  <span class="Identifier">NamedQueue</span><span class="Operator">*</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Keyword">object</span>
    <span class="Comment">## Provides a linked data structure with names</span>
    <span class="Comment">## throughout. It is named for convenience. I'm making</span>
    <span class="Comment">## this comment long to show how you can, too.</span>
    <span class="Identifier">name</span><span class="Operator">*:</span> <span class="Identifier">string</span> <span class="Comment">## The name of the item</span>
    <span class="Identifier">val</span><span class="Operator">*:</span> <span class="Identifier">T</span> <span class="Comment">## Its value</span>
    <span class="Identifier">next</span><span class="Operator">*:</span> <span class="Keyword">ref</span> <span class="Identifier">NamedQueue</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Comment">## The next item in the queue</span></pre><p>Make sure to place the documentation beside or within the object.</p>
<pre class="listing"><span class="Keyword">type</span>
  <span class="Comment">## Bad: this documentation disappears because it annotates the ``type`` keyword</span>
  <span class="Comment">## above, not ``NamedQueue``.</span>
  <span class="Identifier">NamedQueue</span><span class="Operator">*</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Keyword">object</span>
    <span class="Identifier">name</span><span class="Operator">*:</span> <span class="Identifier">string</span> <span class="Comment">## This becomes the main documentation for the object, which</span>
                  <span class="Comment">## is not what we want.</span>
    <span class="Identifier">val</span><span class="Operator">*:</span> <span class="Identifier">T</span> <span class="Comment">## Its value</span>
    <span class="Identifier">next</span><span class="Operator">*:</span> <span class="Keyword">ref</span> <span class="Identifier">NamedQueue</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span> <span class="Comment">## The next item in the queue</span></pre>
<h2><a class="toc-backref" id="documentation-style-var-let-and-const" href="#documentation-style-var-let-and-const">Var, Let, and Const</a></h2><p>When declaring module-wide constants and values, documentation is encouraged. The placement of doc comments is similar to the <tt class="docutils literal"><span class="pre">type</span></tt> sections.</p>
<pre class="listing"><span class="Keyword">const</span>
  <span class="Identifier">X</span><span class="Operator">*</span> <span class="Operator">=</span> <span class="DecNumber">42</span> <span class="Comment">## An awesome number.</span>
  <span class="Identifier">SpreadArray</span><span class="Operator">*</span> <span class="Operator">=</span> <span class="Punctuation">[</span>
    <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span><span class="DecNumber">2</span><span class="Punctuation">,</span><span class="DecNumber">3</span><span class="Punctuation">]</span><span class="Punctuation">,</span>
    <span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span><span class="DecNumber">3</span><span class="Punctuation">,</span><span class="DecNumber">1</span><span class="Punctuation">]</span><span class="Punctuation">,</span>
    <span class="Punctuation">[</span><span class="DecNumber">3</span><span class="Punctuation">,</span><span class="DecNumber">1</span><span class="Punctuation">,</span><span class="DecNumber">2</span><span class="Punctuation">]</span><span class="Punctuation">,</span>
  <span class="Punctuation">]</span> <span class="Comment">## Doc comment for ``SpreadArray``.</span></pre><p>Placement of comments in other areas is usually allowed, but will not become part of the documentation output and should therefore be prefaced by a single hash (<tt class="docutils literal"><span class="pre">#</span></tt>).</p>
<pre class="listing"><span class="Keyword">const</span>
  <span class="Identifier">BadMathVals</span><span class="Operator">*</span> <span class="Operator">=</span> <span class="Punctuation">[</span>
    <span class="FloatNumber">3.14</span><span class="Punctuation">,</span> <span class="Comment"># pi</span>
    <span class="FloatNumber">2.72</span><span class="Punctuation">,</span> <span class="Comment"># e</span>
    <span class="FloatNumber">0.58</span><span class="Punctuation">,</span> <span class="Comment"># gamma</span>
  <span class="Punctuation">]</span> <span class="Comment">## A bunch of badly rounded values.</span></pre><p>Nim supports Unicode in comments, so the above can be replaced with the following:</p>
<pre class="listing"><span class="Keyword">const</span>
  <span class="Identifier">BadMathVals</span><span class="Operator">*</span> <span class="Operator">=</span> <span class="Punctuation">[</span>
    <span class="FloatNumber">3.14</span><span class="Punctuation">,</span> <span class="Comment"># π</span>
    <span class="FloatNumber">2.72</span><span class="Punctuation">,</span> <span class="Comment"># e</span>
    <span class="FloatNumber">0.58</span><span class="Punctuation">,</span> <span class="Comment"># γ</span>
  <span class="Punctuation">]</span> <span class="Comment">## A bunch of badly rounded values (including π!).</span></pre></p>
  
  </div>
</div>

    <div class="row">
      <div class="twelve-columns footer">
        <span class="nim-sprite"></span>
        <br/>
        <small>Made with Nim. Generated: 2019-05-16 23:00:46 UTC</small>
      </div>
    </div>
  </div>
</div>

</body>
</html>

About

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0