Skip to content

Commit

Permalink
Set up the mdbook-replace preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
HU90m authored and marnovandermaas committed Sep 2, 2024
1 parent 20d5121 commit 06b6bb0
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
21 changes: 21 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,24 @@ title = "Sonata Software"
[output.html]
git-repository-url = "https://github.com/lowRISC/sonata-software"
edit-url-template = "https://github.com/lowRISC/sonata-software/edit/main/{path}"

[preprocessor.replace]
after = ["links"]

# Replace all links to a README.md to an index.md
link_replacements = [
{regex = '^(?P<path>[^:#\?]*)README\.md(?P<suffix>[?#].*)?', replacement = '${path}index.md${suffix}'},
]

[[preprocessor.replace.local_link_replacements]]
# Replace all paths pointing to something in the cheriot-rtos
# to a link pointing to them in github.
regex = '^cheriot-rtos/*(?P<path>.*)?'
replacement = 'https://github.com/CHERIoT-Platform/cheriot-rtos/tree/main/${path}'

[[preprocessor.replace.local_link_replacements]]
# Replace all paths pointing to something in this repository,
# that is not a markdown file or image,
# to a link pointing to them in github.
regex = '[^:#\?]*[^(\.(md|svg|png))]([?#].*)?'
replacement = 'https://github.com/lowRISC/sonata-software/tree/main/${0}'
59 changes: 57 additions & 2 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
lowrisc-nix.follows = "sonata-system/lowrisc-nix";
nixpkgs.follows = "lowrisc-nix/nixpkgs";
flake-utils.follows = "lowrisc-nix/flake-utils";
mdutils = {
url = "git+https://codeberg.org/HU90m/mdutils.git";
inputs.nixpkgs.follows = "nixpkgs";
};
};

nixConfig = {
Expand All @@ -20,12 +24,14 @@
flake-utils,
lowrisc-nix,
sonata-system,
mdutils,
}: let
system_outputs = system: let
version = "0.0.1";

pkgs = import nixpkgs {inherit system;};
lrPkgs = lowrisc-nix.outputs.packages.${system};
mdutilsPkgs = mdutils.outputs.packages.${system};
lrDoc = lowrisc-nix.lib.doc {inherit pkgs;};
sonataSystemPkgs = sonata-system.outputs.packages.${system};
cheriotPkgs = lowrisc-nix.outputs.devShells.${system}.cheriot.nativeBuildInputs;
Expand All @@ -48,6 +54,7 @@
root = ./.;
fileset = lrDoc.standardMdbookFileset ./.;
};
buildInputs = [mdutilsPkgs.default];
};

sonata-tests = pkgs.stdenvNoCC.mkDerivation ({
Expand Down Expand Up @@ -156,7 +163,7 @@
devShells = rec {
default = pkgs.mkShell {
name = "sonata-sw";
packages = cheriotPkgs ++ [lrPkgs.uf2conv pkgs.python3Packages.pyserial];
packages = cheriotPkgs ++ [lrPkgs.uf2conv pkgs.python3Packages.pyserial mdutilsPkgs.default];
};
env-with-sim = pkgs.mkShell {
name = "sonata-sw-with-sim";
Expand Down

0 comments on commit 06b6bb0

Please sign in to comment.