-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from Wodann/feature/book
feat(book): add book to main repository
- Loading branch information
Showing
64 changed files
with
1,853 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,25 @@ jobs: | |
- name: Install LLVM | ||
uses: ./.github/actions/install-llvm | ||
|
||
- name: Cargo check | ||
- name: Cargo build | ||
uses: actions-rs/cargo@v1 | ||
continue-on-error: ${{ matrix.config.toolchain == 'nightly' }} | ||
with: | ||
command: build | ||
|
||
- name: Install mdbook | ||
if: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.toolchain == 'stable' }} | ||
uses: actions-rs/[email protected] | ||
with: | ||
crate: mdbook | ||
version: latest | ||
use-tool-cache: true | ||
|
||
- name: mdbook test | ||
if: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.toolchain == 'stable' }} | ||
run: mdbook test book -L target/debug/deps | ||
|
||
- name: Cargo test | ||
uses: actions-rs/cargo@v1 | ||
continue-on-error: ${{ matrix.config.toolchain == 'nightly' }} | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ Cargo.lock | |
|
||
# Build artifacts | ||
*.munlib | ||
**/target/* | ||
**/target/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
[submodule "crates/mun_abi/c"] | ||
path = crates/mun_abi/c | ||
url = ../../mun-lang/abi-c | ||
url = https://github.com/mun-lang/abi-c.git | ||
[submodule "crates/mun_runtime_capi/ffi"] | ||
path = crates/mun_runtime_capi/ffi | ||
url = ../../mun-lang/runtime-ffi.git | ||
url = https://github.com/mun-lang/runtime-ffi.git | ||
[submodule "book/vendor/highlight.js"] | ||
path = book/vendor/highlight.js | ||
url = https://github.com/mun-lang/highlight.js.git | ||
branch = add-mun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/book | ||
/theme/highlight.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[book] | ||
authors = ["The Mun Team <[email protected]>"] | ||
language = "en" | ||
multilingual = false | ||
src = "src" | ||
title = "The Mun Programming Language" | ||
|
||
[output.html] | ||
additional-css = ["theme/mun.css"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
pushd ./book | ||
|
||
# First build our custom highlight.js | ||
./ci/build-highlight-js | ||
|
||
# Check if mdbook is installed, otherwise download the binaries | ||
mdbook="mdbook" | ||
if ! [ -x "$(command -v $mdbook)" ]; then | ||
echo "Installing mdbook.." | ||
curl -sL https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.1/mdbook-v0.3.1-x86_64-unknown-linux-gnu.tar.gz | tar zxv | ||
mdbook="./mdbook" | ||
fi | ||
|
||
# Actually build the book | ||
echo 'Building book..' | ||
$mdbook build | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
main() { | ||
# prepare the git submodule, if it hasn't been already | ||
git submodule init | ||
|
||
# build the minified highlight.js source | ||
pushd vendor/highlight.js | ||
npm install | ||
node tools/build.js rust bash mun cpp c typescript | ||
popd | ||
|
||
# copy the minified sources to the theme directory | ||
mkdir -p theme | ||
cp vendor/highlight.js/build/highlight.pack.js theme/highlight.js | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
pub fn fibonacci_n() -> i64 { | ||
let n = arg(); | ||
fibonacci(n); | ||
} | ||
|
||
fn arg() -> i64 { | ||
5 | ||
} | ||
|
||
fn fibonacci(n: i64) -> i64 { | ||
if n <= 1 { | ||
n | ||
} else { | ||
fibonacci(n - 1) + fibonacci(n - 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pub fn arg() -> i64 { | ||
5 | ||
} | ||
|
||
pub fn fibonacci(n: i64) -> i64 { | ||
if n <= 1 { | ||
n | ||
} else { | ||
fibonacci(n - 1) + fibonacci(n - 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <iostream> | ||
|
||
#include "mun/runtime.h" | ||
|
||
int main() { | ||
if (argc < 2) { | ||
return 1; | ||
} | ||
|
||
auto lib_path = argv[1]; | ||
if (auto runtime = mun::make_runtime(lib_path)) { | ||
while (true) { | ||
auto arg = mun::invoke_fn<int64_t>(*runtime, "arg").wait(); | ||
auto result = | ||
mun::invoke_fn<int64_t>(*runtime, "fibonacci", arg).wait(); | ||
std::cout << "fibonacci(" << std::to_string(arg) << ") = " << result | ||
<< std::endl; | ||
|
||
runtime->update(); | ||
} | ||
} | ||
|
||
return 2; | ||
} |
Oops, something went wrong.