-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Austin Seipp <[email protected]>
- Loading branch information
1 parent
916dc30
commit 0bd1951
Showing
4 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,19 @@ | ||
[package] | ||
name = "jj-docs" | ||
description = "Documentation for Jujutsu - an experimental version control system" | ||
autotests = false | ||
|
||
version = { workspace = true } | ||
edition = { workspace = true } | ||
rust-version = { workspace = true } | ||
license = { workspace = true } | ||
homepage = { workspace = true } | ||
repository = { workspace = true } | ||
documentation = { workspace = true } | ||
readme = { workspace = true } | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[dependencies] | ||
rust-embed = { workspace = true } |
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,40 @@ | ||
// Copyright 2024 The Jujutsu Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::borrow::Cow; | ||
|
||
#[derive(rust_embed::RustEmbed)] | ||
#[folder = "."] | ||
#[include = "*.md"] | ||
struct DocAssetsMd; | ||
|
||
pub struct DocAssets; | ||
|
||
/// Documentation assets, allowing you to look up and iterate all the documents | ||
/// available. | ||
impl DocAssets { | ||
// This is a simple wrapper around the `DocAssetsMd` | ||
// struct that handles trimming off Markdown `.md` extensions, so that users | ||
// can refer to documentation items without needing to know the file extension. | ||
|
||
/// Iterator. Returns all the documentation items available. | ||
pub fn iter() -> impl Iterator<Item = String> { | ||
DocAssetsMd::iter().map(|name| name.trim_end_matches(".md").to_owned()) | ||
} | ||
|
||
pub fn get(name: &str) -> Option<Cow<'static, [u8]>> { | ||
// re-attach the `.md` extension before lookup | ||
DocAssetsMd::get(&format!("{}.md", name)).map(|data| data.data) | ||
} | ||
} |