Skip to content

Commit

Permalink
Update documentation (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe authored Sep 6, 2022
1 parent 5081dc3 commit 9fc72fa
Show file tree
Hide file tree
Showing 52 changed files with 263 additions and 231 deletions.
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"lcov",
"libc",
"malloc",
"mdbook",
"mkdocs",
"modifiability",
"mtriple",
"optarg",
Expand Down
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ updates:
directory: /
schedule:
interval: daily
- package-ecosystem: npm
directory: /doc
schedule:
interval: daily
- package-ecosystem: pip
directory: /doc
schedule:
interval: daily
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
steps:
- uses: actions/checkout@main
- run: tools/ci/github/setup.sh
- run: tools/build_documents.sh
- run: tools/document/build.sh
- uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: doc/book
publish_dir: doc/site
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*.svg
*.tar.*
.pen
assets
dhat-*
site
target
tmp
5 changes: 0 additions & 5 deletions doc/.gitignore

This file was deleted.

Empty file removed doc/.nojekyll
Empty file.
21 changes: 0 additions & 21 deletions doc/book.toml

This file was deleted.

1 change: 1 addition & 0 deletions doc/docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pen-lang.org
14 changes: 7 additions & 7 deletions doc/src/README.md → doc/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img width="300px" src="/favicon.svg" /></p>
<p align="center"><img width="300px" src="icon.svg" /></p>

# Pen programming language

Expand Down Expand Up @@ -42,13 +42,13 @@ Pen aims to make large-scale software development efficient where many engineers

### Minimal language

- Its [syntax][syntax] and [type system](/references/language/types.md) are small, simple, and easy to learn.
- Its [syntax][syntax] and [type system](references/language/types.md) are small, simple, and easy to learn.
- Yet, the language supports all the modern features.

### Concurrent/parallel computation

- The language and its runtime enables thread-safe concurrent/parallel computation.
- For more information, see [Concurrency and parallelism](/guides/concurrency-and-parallelism.md).
- For more information, see [Concurrency and parallelism](guides/concurrency-and-parallelism.md).

### Reliable testing

Expand All @@ -75,13 +75,13 @@ Pen aims to make large-scale software development efficient where many engineers
- Pure functions by default
- [Errors as values][error-handling]
- Asynchronous I/O
- [Cross compile](/advanced-features/cross-compile.md)
- [Cross compile](advanced-features/cross-compile.md)
- [Rust](https://www.rust-lang.org/)/C Foreign Function Interface (FFI)

## License

Pen is dual-licensed under [MIT](https://github.com/pen-lang/pen/blob/main/LICENSE-MIT) and [Apache 2.0](https://github.com/pen-lang/pen/blob/main/LICENSE-APACHE).

[error-handling]: /references/language/syntax.md#error-handling
[syntax]: /references/language/syntax.md
[system-packages]: /advanced-features/writing-system-packages.md
[error-handling]: references/language/syntax.md#error-handling
[syntax]: references/language/syntax.md
[system-packages]: advanced-features/writing-system-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Run `pen build --help` to see all supported targets.

## System package support

Cross compile support of [system packages](/references/language/packages.md#system-packages) are totally up to their developers. For example, [the `Os` standard system package](/references/standard-packages/os.md) supports most targets as long as their platforms expose OS-like APIs. However, some custom system packages might not support those targets because of their limited use cases.
Cross compile support of [system packages](../references/language/packages.md#system-packages) are totally up to their developers. For example, [the `Os` standard system package](../references/standard-packages/os.md) supports most targets as long as their platforms expose OS-like APIs. However, some custom system packages might not support those targets because of their limited use cases.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Using FFI, you can import or export functions in foreign languages, such as [Rus

## Importing functions in foreign languages

You can import functions in foreign languages using [foreign import statements](/references/language/syntax.md#foreign-import-statement). The statements specify the foreign functions' calling convention, names and types.
You can import functions in foreign languages using [foreign import statements](../references/language/syntax.md#foreign-import-statement). The statements specify the foreign functions' calling convention, names and types.

You might specify calling conventions of foreign functions in a format of string literals after `import foreign` keywords optionally. Currently, only the C calling convention is supported as `"c"`. If the options are omitted, the functions are imported with the native calling convention of Pen.

Expand All @@ -16,7 +16,7 @@ import foreign "c" foo \(number, number) number
## Exporting functions to foreign languages

You can export functions to foreign languages using [foreign function definitions](/references/language/syntax.md#foreign-function-definition), which have `foreign` keywords in front of normal function definitions.
You can export functions to foreign languages using [foreign function definitions](../references/language/syntax.md#foreign-function-definition), which have `foreign` keywords in front of normal function definitions.

You might specify calling conventions of exported foreign functions optionally after `foreign` keywords as well as [imported foreign functions](#importing-functions-in-foreign-languages).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Using existing system packages covers most use cases in application development.
- Define your own system interfaces of functions and types with side effects.
- Link applications in arbitrary file formats.

This page assumes that you have already read [Packages](/references/language/packages.md).
This page assumes that you have already read [Packages](../references/language/packages.md).

> Caveat: Providing bad system packages which do not conform to conventions can break the ecosystem of the language! In the worst cases, they might make applications malfunction. Please be careful to follow the conventions to keep applications maintainable and portable.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ This page describes how to build an executable of a program written in Pen. It c

## Creating an application package

[Application packages](/references/language/packages.md#application-packages) are packages that are built into executables.
[Application packages](../references/language/packages.md#application-packages) are packages that are built into executables.
To create it, you run a `pen create` command with your application's name (e.g. `foo`) in your terminal.

```sh
pen create foo
```

Then, you should see a `foo` directory in your current directory. When you go there, you should see a `main.pen` source file and a `pen.json` file for [package configuration](/references/language/packages.md#package-configuration).
Then, you should see a `foo` directory in your current directory. When you go there, you should see a `main.pen` source file and a `pen.json` file for [package configuration](../references/language/packages.md#package-configuration).

`main.pen`:

Expand All @@ -39,7 +39,7 @@ main = \(ctx context) none {
}
```

In this example, the `main.pen` file contains a program that outputs a text, "Hello, world!" in a terminal. And the `pen.json` configuration file defines a package type of `application` and its dependencies. Here, it has only a dependency of the `Os` [system package](/references/language/packages.md#system-packages).
In this example, the `main.pen` file contains a program that outputs a text, "Hello, world!" in a terminal. And the `pen.json` configuration file defines a package type of `application` and its dependencies. Here, it has only a dependency of the `Os` [system package](../references/language/packages.md#system-packages).

## Building a package into an executable

Expand All @@ -59,4 +59,4 @@ Then, you will see an executable file named `app` in the directory. Now, you can

- [Creating a library](creating-a-library.md)
- [Using a library](using-a-library.md)
- [Language syntax](/references/language/syntax.md)
- [Language syntax](../references/language/syntax.md)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pen provides several built-in functions for concurrent and parallel programming.

### `go` function

[The `go` built-in function](/references/language/built-ins.html#go) runs a given function concurrently, and possibly in parallel.
[The `go` built-in function](../references/language/built-ins.md#go) runs a given function concurrently, and possibly in parallel.

```pen
future = go(\() number {
Expand All @@ -20,11 +20,11 @@ future = go(\() number {

The `go` function returns a function of the same type as the given argument. The returned function returns a resulting value of the function execution. In other languages, such functions returning values computed concurrently when they are ready are also known as [futures](https://doc.rust-lang.org/std/future/trait.Future.html) or [promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).

The `go` function may or may not run a given function immediately depending on its implementation. For example, [the standard `Os` system package](/references/standard-packages/os.md) runs the given function in parallel if multiple CPU cores are available.
The `go` function may or may not run a given function immediately depending on its implementation. For example, [the standard `Os` system package](../references/standard-packages/os.md) runs the given function in parallel if multiple CPU cores are available.

### `race` function

[The `race` built-in function](/references/language/built-ins.html#race) takes multiple lists and merge them into one by evaluating elements in each list concurrently and possibly in parallel. The resulting list contains the elements in the original lists in order of their finished times of computation. Remember that elements in lists are evaluated lazily.
[The `race` built-in function](../references/language/built-ins.md#race) takes multiple lists and merge them into one by evaluating elements in each list concurrently and possibly in parallel. The resulting list contains the elements in the original lists in order of their finished times of computation. Remember that elements in lists are evaluated lazily.

```pen
zs = race([[number] xs, ys])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ This page describes how to create a library in Pen. It consists of the following

## Creating a library package

[Library packages](/references/language/packages.md#library-packages) are packages imported and used by other packages.
[Library packages](../references/language/packages.md#library-packages) are packages imported and used by other packages.
To create it, you run a `pen create --library` command with your library's name (e.g. `foo`) in your terminal.

```sh
pen create --library foo
```

Then, you should see a `foo` directory in your current directory. When you go there, you should see a `Foo.pen` source file and a `pen.json` file for [package configuration](/references/language/packages.md#package-configuration).
Then, you should see a `foo` directory in your current directory. When you go there, you should see a `Foo.pen` source file and a `pen.json` file for [package configuration](../references/language/packages.md#package-configuration).

`Foo.pen`:

Expand Down Expand Up @@ -52,4 +52,4 @@ Now, your package is ready for use by other packages!

- [Building an executable](building-an-executable.md)
- [Using a library](using-a-library.md)
- [Language syntax](/references/language/syntax.md)
- [Language syntax](../references/language/syntax.md)
2 changes: 1 addition & 1 deletion doc/src/guides/testing.md → doc/docs/guides/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CheckFoo = \() none | error {

### The `Test` package

[The `Test` standard package](/references/standard-packages/test.md) includes some utilities which helps you to write tests.
[The `Test` standard package](../references/standard-packages/test.md) includes some utilities which helps you to write tests.

## Running tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This page describes how to use a library in Pen. It consists of the following st

## Modifying package configuration

To use a library package, you need to add the package as a dependency in another package. To add the dependency, you modify a `pen.json` configuration file in the package adding the library package's name (e.g. `Foo`) and URL (e.g. `git://github.com/your-name/foo`) in a `dependencies` field like the following example. Note that you need to specify a `git` protocol scheme for library packages published as Git repositories. For other kinds of library packages, see [Package configuration](/references/language/packages.md#package-configuration).
To use a library package, you need to add the package as a dependency in another package. To add the dependency, you modify a `pen.json` configuration file in the package adding the library package's name (e.g. `Foo`) and URL (e.g. `git://github.com/your-name/foo`) in a `dependencies` field like the following example. Note that you need to specify a `git` protocol scheme for library packages published as Git repositories. For other kinds of library packages, see [Package configuration](../references/language/packages.md#package-configuration).

```json
{
Expand Down Expand Up @@ -40,5 +40,5 @@ MyFunction = \(x number, y number) number {

- [Building an executable](building-an-executable.md)
- [Creating a library](creating-a-library.md)
- [Language syntax](/references/language/syntax.md)
- [Import statement](/references/language/syntax.md#import-statement)
- [Language syntax](../references/language/syntax.md)
- [Import statement](../references/language/syntax.md#import-statement)
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Getting started

## Install

See [Install](install.md).
# Building the first program

## Creating a package

Expand All @@ -12,7 +8,7 @@ To create your first package, run a `pen create` command with your package's nam
pen create foo
```

Then, you should see a directory named `foo` in your current directory. When you go into the directory, you should see a `main.pen` source file and a `pen.json` file for [package configuration](/references/language/packages.md#package-configuration).
Then, you should see a directory named `foo` in your current directory. When you go into the directory, you should see a `main.pen` source file and a `pen.json` file for [package configuration](../references/language/packages.md#package-configuration).

## Building a package

Expand All @@ -32,8 +28,8 @@ Now, you can start editing source files and build your own application in Pen!

## Next steps

- To use other library packages, see [Using a library](/guides/using-a-library.md).
- For more code examples, see [Examples](/examples).
- For the language syntax, see [Syntax](/references/language/syntax.md) and [Types](/references/language/types.md).
- For usage of the standard packages, see [Standard packages](/references/standard-packages).
- To add more modules in your package, see [Modules](/references/language/modules.md).
- To use other library packages, see [Using a library](../guides/using-a-library.md).
- For more code examples, see [Examples](../examples/types/number.md).
- For the language syntax, see [Syntax](../references/language/syntax.md) and [Types](../references/language/types.md).
- For usage of the standard packages, see [Standard packages](../references/standard-packages/core.md).
- To add more modules in your package, see [Modules](../references/language/modules.md).
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Foo = \() number {

## Importing functions and types from modules

In order to import functions and types from other modules, place [import statements](/references/language/syntax.md#import-statement) at the top of modules.
In order to import functions and types from other modules, place [import statements](syntax.md#import-statement) at the top of modules.

The first components in the statements are names of external packages you declare in [package configuration files][package-configuration] (`Foo`.) They are omitted if imported modules are in the same packages. The rest of the components are directory names where the modules exist (`Bar`) and the modules' filenames without their file extensions (`Baz` for `Baz.pen`.)

Expand Down Expand Up @@ -74,11 +74,9 @@ Imported modules can have custom prefixes given different names after the `as` k
import Foo'Bar'Baz as Blah
```

[package-configuration]: packages.md#package-configuration

### Unqualified import

You can import functions and types without prefixes by putting their names between `{` and `}` in [import statements](/references/language/syntax.md#import-statement). This is especially useful when module names and imported functions or types have the same names like `import 'MyType { MyType }`.
You can import functions and types without prefixes by putting their names between `{` and `}` in [import statements](syntax.md#import-statement). This is especially useful when module names and imported functions or types have the same names like `import 'MyType { MyType }`.

```pen
import Foo'Bar { Foo, Bar }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Packages

Packages are sets of [modules](/references/language/modules.md). Like modules, packages can import other packages specifying them in [their configurations](#package-configuration).
Packages are sets of [modules](modules.md). Like modules, packages can import other packages specifying them in [their configurations](#package-configuration).

## What composes a package?

The following entities compose packages.

- Standard packages bundled in [installation](/introduction/install.md) of the language
- Standard packages bundled in [installation](../../introduction/install.md) of the language
- Remote repositories managed by version control systems (VCS)
- Currently, Pen supports only [Git](https://git-scm.com/) as a VCS.
- Directories with [package configuration files](#package-configuration) on file systems
Expand Down Expand Up @@ -42,7 +42,7 @@ System packages contain functions and types that have side effects to provide sy

Although they can be imported by library packages as well as application packages, then they are expected not to cause any side effects.

If you want to write your own system packages, see [Writing system packages](/advanced-features/writing-system-packages.md).
If you want to write your own system packages, see [Writing system packages](../../advanced-features/writing-system-packages.md).

## Package configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Foo'Bar

It imports a function from a foreign language.

See [Foreign Function Interface (FFI)](/advanced-features/ffi.md) for more details.
See [Foreign Function Interface (FFI)](../../advanced-features/ffi.md) for more details.

```pen
import foreign "c" foo \(number, number) number
Expand Down Expand Up @@ -65,7 +65,7 @@ foo = \(x number, y number) number {

It defines a function exported to foreign languages.

See [Foreign Function Interface (FFI)](/advanced-features/ffi.md) for more details.
See [Foreign Function Interface (FFI)](../../advanced-features/ffi.md) for more details.

```pen
foreign "c" foo = \(x number, y number) number {
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 4 additions & 12 deletions doc/src/the-zen.md → doc/docs/the-zen.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
# The Zen

- Beautiful is better than ugly.
- Explicit is better than implicit.
- Simple is better than complex.
- Explicit is better than implicit.
- Clear is better than clever.
- One way to do one thing
- Single solution for multiple problems
- One solution for many problems
- Steady value over volatile value

## Language qualities

In the order of priority,

- Simplicity
- Readability
- Consistency
- Writability

## References

- [Go Proverbs](https://go-proverbs.github.io/)
- [The Zen of Python](https://www.python.org/dev/peps/pep-0020/)
- [Zen | The Zig programming language](https://ziglang.org/documentation/master/#Zen)
Loading

0 comments on commit 9fc72fa

Please sign in to comment.