Skip to content

Commit

Permalink
Contracts update and grouped together "getting started" content (#86)
Browse files Browse the repository at this point in the history
* updating getting started section

* fixing contract syntax in examples
  • Loading branch information
joshring authored Nov 9, 2024
1 parent 408df8e commit e022529
Show file tree
Hide file tree
Showing 25 changed files with 224 additions and 209 deletions.
166 changes: 83 additions & 83 deletions .astro/astro/content.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .astro/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"enabled": false
},
"_variables": {
"lastUpdateCheck": 1727778140156
"lastUpdateCheck": 1731177782673
}
}
31 changes: 25 additions & 6 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,47 @@ import fs from "node:fs"

// https://astro.build/config
export default defineConfig({
i18n: {
defaultLocale: "en",
locales: ["en"],
},
site: "https://c3-lang.org",
redirects: {
'/guide': '/introduction',
'guide/basic-types-and-values/': '/language-fundamentals/basic-types-and-values',
'/guide': '/getting-started',
'/introduction': '/getting-started',

'/guide/basic-types-and-values': '/language-fundamentals/basic-types-and-values',

'/guide/my-first-hello-world': '/getting-started/hello-world',
'/guide/my-first-project': '/getting-started/projects',
'/references/development': '/get-involved',
'/references': '/introduction/design-goals',

'/references': '/getting-started/design-goals',
'/introduction/design-goals': '/getting-started/design-goals',

'/references/getting-started/prebuilt-binaries': '/getting-started/prebuilt-binaries',
'/install-c3/prebuilt-binaries': '/getting-started/prebuilt-binaries',

'/references/getting-started/setup': '/getting-started/compile',
'/install-c3/compile': '/getting-started/compile',

'/references/docs/examples': '/language-overview/examples',
'/references/getting-started/prebuilt-binaries': '/install-c3/prebuilt-binaries',
'/references/getting-started/setup': '/install-c3/compile',
'/references/getting-started/primer': '/language-overview/primer',


'/references/getting-started/allfeatures': '/faq/allfeatures',
'/introduction/roadmap' :'/getting-started/roadmap',
'/compare': '/faq/compare-languages',
'/references/docs/compare': '/faq/compare-languages'

},
integrations: [
tailwind({
applyBaseStyles: false,
}),
starlight({
favicon: "ico.svg",
title: "The C3 Guide",
title: "C3",
customCss: ["./src/content/docs.css"],
expressiveCode: {
shiki: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/community.astro
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
>
<a
class="flex flex-col h-full text-center rounded-md hover:bg-gray-100 p-4 sm:p-6 dark:hover:bg-white/[.05]"
href="install-c3/prebuilt-binaries/"
href="/getting-started/prebuilt-binaries"
>
<box-icon
class="w-24 h-24 mx-auto text-black dark:text-white"
Expand All @@ -171,7 +171,7 @@
</a>
<a
class="flex flex-col h-full text-center rounded-md hover:bg-gray-100 p-4 sm:p-6 dark:hover:bg-white/[.05]"
href="introduction/"
href="/getting-started"
>
<box-icon
class="w-24 h-24 mx-auto text-black dark:text-white"
Expand Down
4 changes: 2 additions & 2 deletions src/components/hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import Navbar from "./navbar.astro";
dark:hover:border-blue-500
dark:border-blue-600
dark:text-white"
href="introduction"
href="/getting-started"
>
Get started
<svg
Expand Down Expand Up @@ -122,7 +122,7 @@ import Navbar from "./navbar.astro";
</svg>
<a
class="inline-flex items-center gap-x-1.5 text-sm text-blue-600 decoration-2 hover:underline font-medium"
href="/install-c3/prebuilt-binaries"
href="/getting-started/prebuilt-binaries"
>
Installation Guide
<svg
Expand Down
11 changes: 3 additions & 8 deletions src/components/navbar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,17 @@
<div
class="flex flex-col gap-y-4 gap-x-0 mt-5 sm:flex-row sm:items-center sm:justify-end sm:gap-y-0 sm:gap-x-7 sm:mt-0 sm:pl-7"
>
<a
class="font-medium text-blue-600 sm:py-6 dark:text-blue-500"
href="#"
aria-current="page">Home</a
>
<a
class="font-medium text-gray-500 hover:text-blue-500 sm:py-6 dark:text-gray-400 dark:hover:text-blue-500"
href="introduction/">The C3 Guide</a
href="/getting-started/">Docs</a
>
<a
class="font-medium text-gray-500 hover:text-blue-500 sm:py-6 dark:text-gray-400 dark:hover:text-blue-500"
href="language-overview/examples">Examples</a
href="/language-overview/examples">Examples</a
>
<a
class="font-medium text-gray-500 hover:text-blue-500 sm:py-6 dark:text-gray-400 dark:hover:text-blue-500"
href="install-c3/prebuilt-binaries/">Download</a
href="/getting-started/prebuilt-binaries">Download</a
>
<a
class="font-medium text-gray-500 hover:text-blue-500 sm:py-6 dark:text-gray-400 dark:hover:text-blue-500"
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/FAQ/allfeatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ but nonetheless provided unique functionality:

## Contracts

1. Doc comments (starting with `/**`) are parsed.
1. Doc comments (starting with `<*`) are parsed.
2. The first part, up until the first `@` directive is ignored.
3. The `@param` directive for pointer arguments may define usage constraints `[in]` `[out]` and `[inout]`.
4. Pointer argument constraints may add a `&` prefix to indicate that they may not be `null`, e.g. `[&inout]`.
Expand Down
10 changes: 5 additions & 5 deletions src/content/docs/FAQ/changesfromc.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Notably bit operations have higher precedence than +/-, making code like this: `
The const qualifier is only retained for actual constant variables. C3 uses a special type of [post condition](/language-common/contracts/) for functions to indicate that they do not alter in parameters.

```c3
/**
* This function ensures that foo is not changed in the function.
* @param [in] foo
* @param [out] bar
**/
<*
This function ensures that foo is not changed in the function.
@param [in] foo
@param [out] bar
*>
fn void test(Foo* foo, Bar* bar)
{
bar.y = foo.x;
Expand Down
8 changes: 4 additions & 4 deletions src/content/docs/Generic Programming/generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ foo_test::test(<int, double>)(1.0, &g);
Just like for macros, optional constraints may be added to improve compile errors:

```c3
/**
* @require $assignable(1, TypeB) && $assignable(1, TypeC)
* @require $assignable((TypeB)1, TypeA) && $assignable((TypeC)1, TypeA)
*/
<*
@require $assignable(1, TypeB) && $assignable(1, TypeC)
@require $assignable((TypeB)1, TypeA) && $assignable((TypeC)1, TypeA)
*>
module vector(<TypeA, TypeB, TypeC>);
/* .. code * ../
Expand Down
18 changes: 9 additions & 9 deletions src/content/docs/Generic Programming/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ The parameters have different sigils: `$` means compile time evaluated (constant
A basic swap:
```c3
/**
* @checked $assignable(*a, $typeof(*b)) && $assignable(*b, $typeof(*a))
*/
<*
@checked $assignable(*a, $typeof(*b)) && $assignable(*b, $typeof(*a))
*>
macro void @swap(&a, &b)
{
$typeof(*a) temp = *a;
Expand Down Expand Up @@ -297,12 +297,12 @@ To accept a trailing block, `; @name(param1, ...)` is placed after declaring the
Here's an example to illustrate its use:

```c3
/**
* A macro looping through a list of values, executing the body once
* every pass.
*
* @require $defined(a.len) && $defined(a[0])
**/
<*
A macro looping through a list of values, executing the body once
every pass.

@require $defined(a.len) && $defined(a[0])
*>
macro @foreach(a; @body(index, value))
{
for (int i = 0; i < a.len; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ description: Build C3 From Source
sidebar:
order: 21
---
C3 has [precompiled binaries for Windows, MacOS and Ubuntu](/install-c3/prebuilt-binaries/).

:::note[Want To Download Pre-Built C3 Binaries?]
[Download C3](/getting-started/prebuilt-binaries/), available on Mac, Windows and Linux.
:::

For other platforms it should be possible to compile it on any platform LLVM can compile to. You will need `git` and `CMake` installed.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ sidebar:
order: 2
---

:::note[Want To Download C3?]
[Download C3](/getting-started/prebuilt-binaries/), available on Mac, Windows and Linux.
:::

## Design goals

- Procedural language, with a pragmatic ethos to get work done.
Expand Down Expand Up @@ -37,21 +41,6 @@ state.*
- [Cross-platform standard library which includes dynamic containers and strings](/standard-library/)
- LLVM backend

## How to get C3
The C3 compiler can be found on github: [https://github.com/c3lang/c3c](https://github.com/c3lang/c3c).

Binaries are directly downloadable for the following platforms:

- Windows x64 [download](https://github.com/c3lang/c3c/releases/download/latest/c3-windows.zip),
[install instructions](/install-c3/prebuilt-binaries/#installing-on-windows).
- MacOS x64 [download](https://github.com/c3lang/c3c/releases/download/latest/c3-macos.zip),
[install instructions](/install-c3/prebuilt-binaries/#installing-on-mac-arm64).
- Ubuntu x64 [download](https://github.com/c3lang/c3c/releases/download/latest/c3-ubuntu-20.tar.gz),
[install instructions](/install-c3/prebuilt-binaries/#installing-on-ubuntu).
- Debian x64 [download](https://github.com/c3lang/c3c/releases/download/latest/c3-linux.tar.gz),
[install instructions](/install-c3/prebuilt-binaries/#installing-on-debian).
- Arch [install instructions](/install-c3/prebuilt-binaries/#installing-on-arch-linux)

## C3 Background

C3 is an evolution of C, a minimalistic language designed for systems
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/Getting Started/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
---

:::note[Not installed the C3 compiler yet?]
[Download C3](/install-c3/prebuilt-binaries/), available on Mac, Windows and Linux.
[Download C3](/getting-started/prebuilt-binaries), available on Mac, Windows and Linux.
:::

## 👋 Hello world
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
---
title: The C3 Guide
title: What Is C3?
description: A guide to the C3 Programming Language
sidebar:
order: 1
---

## What is C3?
:::note[Want To Download C3?]
[Download C3](/getting-started/prebuilt-binaries/), available on Mac, Windows and Linux.
:::

C3 is an evolution of C and a minimalist systems programming language, featuring:

## C3 Programming Language

C3 is an evolution of C and a minimalist systems programming language.

### 🦺 Ergonomics **and** Safety
- Optionals to safely and quickly handle errors and null.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/Getting Started/projects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar:
import { FileTree } from '@astrojs/starlight/components';

:::note[Not installed the C3 compiler yet?]
[Download C3](/install-c3/prebuilt-binaries/), available on Mac, Windows and Linux.
[Download C3](/getting-started/prebuilt-binaries/), available on Mac, Windows and Linux.
:::

## Projects in C3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ sidebar:
---


:::note[Want To Download C3?]
[Download C3](/getting-started/prebuilt-binaries/), available on Mac, Windows and Linux.
:::

## C3 Roadmap

### C3 Is Feature Stable
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/Implementation Details/specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ There are three types of regular comments:

### Doc comments

1. `/** text **/` doc block comment. The text between `/**` and `**/` is optionally parsed using the doc comment
syntactic grammar. A compiler may choose to read `/** text **/` as a regular comment.
1. `<* text *>` doc block comment. The text between `<*` and `*>` is optionally parsed using the doc comment
syntactic grammar. A compiler may choose to read `<* text *>` as a regular comment.

### Identifiers

Expand Down
Loading

0 comments on commit e022529

Please sign in to comment.