Skip to content

Commit

Permalink
Merge pull request #1916 from DogeDark/master
Browse files Browse the repository at this point in the history
Add Prerelease Doc Generation
  • Loading branch information
ealmloff authored Feb 9, 2024
2 parents 0a4603d + 002de62 commit f4651ce
Show file tree
Hide file tree
Showing 29 changed files with 191 additions and 425 deletions.
60 changes: 24 additions & 36 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,37 @@
name: github pages

name: Deploy Nightly Docs
on:
workflow_dispatch:
# push:
# paths:
# - docs/**
# - .github/workflows/docs.yml
# branches:
# - master

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
push:
branches:
- master

jobs:
build-deploy:
deploy:
name: Build & Deploy
runs-on: ubuntu-latest
environment: docs
steps:

# NOTE: Comment out when https://github.com/rust-lang/mdBook/pull/1306 is merged and released
# - name: Setup mdBook
# uses: peaceiris/actions-mdbook@v1
# with:
# mdbook-version: "0.4.10"
permissions:
contents: write

# NOTE: Delete when the previous one is enabled
- name: Setup mdBook
run: |
cargo install mdbook --git https://github.com/Demonthos/mdBook.git --branch master
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/master' }}
- uses: ilammy/setup-nasm@v1

- name: Build
run: cd docs &&
cd guide && mdbook build -d ../nightly/guide && cd .. &&
cd router && mdbook build -d ../nightly/router && cd ..
# cd reference && mdbook build -d ../nightly/reference && cd .. &&
# cd fermi && mdbook build -d ../nightly/fermi && cd ..
- name: cargo doc
run: cargo doc --no-deps --workspace --all-features

- name: Deploy 🚀
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs/nightly # The folder the action should deploy.
target-folder: docs/nightly
branch: gh-pages
folder: target/doc
target-folder: api-docs/nightly
repository-name: dioxuslabs/docsite
clean: false
token: ${{ secrets.DEPLOY_KEY }} # let's pretend I don't need it for now

6 changes: 0 additions & 6 deletions packages/cli/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ async fn setup_file_watcher<F: Fn() -> Result<BuildResult> + Send + 'static>(
},
web_info.clone(),
);

#[cfg(feature = "plugin")]
let _ = PluginManager::on_serve_rebuild(
chrono::Local::now().timestamp(),
e.paths,
);
}
Err(e) => {
last_update_time = chrono::Local::now().timestamp();
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/error_boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ impl ErrorBoundary {
///
/// ```rust, ignore
/// #[component]
/// fn app( count: String) -> Element {
/// fn app(count: String) -> Element {
/// let id: i32 = count.parse().throw()?;
///
/// rsx! {
/// div { "Count {}" }
/// })
/// }
/// }
/// ```
pub trait Throw<S = ()>: Sized {
Expand All @@ -170,7 +170,7 @@ pub trait Throw<S = ()>: Sized {
///
/// rsx! {
/// div { "Count {}" }
/// })
/// }
/// }
/// ```
fn throw(self) -> Option<Self::Out>;
Expand All @@ -193,7 +193,7 @@ pub trait Throw<S = ()>: Sized {
///
/// rsx! {
/// div { "Count {}" }
/// })
/// }
/// }
/// ```
fn throw_with<D: Debug + 'static>(self, e: impl FnOnce() -> D) -> Option<Self::Out> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<T: std::fmt::Debug> std::fmt::Debug for Event<T> {
/// button {
/// onclick: move |evt| cx.onclick.call(evt),
/// }
/// })
/// }
/// }
///
/// ```
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub(crate) mod innerlude {
/// An Errored [`Element`] will propagate the error to the nearest error boundary.
pub type Element = Option<VNode>;

/// A [`Component`] is a function that takes a [`Scope`] and returns an [`Element`].
/// A [`Component`] is a function that takes [`Properties`] and returns an [`Element`].
///
/// Components can be used in other components with two syntax options:
/// - lowercase as a function call with named arguments (rust style)
Expand Down Expand Up @@ -84,7 +84,7 @@ pub use crate::innerlude::{

/// The purpose of this module is to alleviate imports of many common types
///
/// This includes types like [`Scope`], [`Element`], and [`Component`].
/// This includes types like [`Element`], and [`Component`].
pub mod prelude {
pub use crate::innerlude::{
consume_context, consume_context_from_scope, current_scope_id, fc_to_builder, flush_sync,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/virtual_dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::{any::Any, collections::BTreeSet, rc::Rc};
///
/// ## Guide
///
/// Components are defined as simple functions that take [`Scope`] and return an [`Element`].
/// Components are defined as simple functions that take [`crate::properties::Properties`] and return an [`Element`].
///
/// ```rust
/// # use dioxus::prelude::*;
Expand Down Expand Up @@ -218,7 +218,7 @@ impl VirtualDom {
/// # Example
/// ```rust, ignore
/// fn Example() -> Element {
/// rsx!( div { "hello world" } ))
/// rsx!( div { "hello world" } )
/// }
///
/// let dom = VirtualDom::new(Example);
Expand Down Expand Up @@ -526,7 +526,7 @@ impl VirtualDom {
///
/// # Example
/// ```rust, ignore
/// static app: Component = |cx| rsx!{ "hello world" });
/// static app: Component = |cx| rsx!{ "hello world" };
///
/// let mut dom = VirtualDom::new();
/// let edits = dom.rebuild();
Expand Down
3 changes: 3 additions & 0 deletions packages/dioxus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ warp = ["dioxus-fullstack?/warp", "ssr", "dioxus-liveview?/warp"]
rocket = ["dioxus-liveview?/rocket"]
tui = ["dioxus-tui", "dioxus-config-macro/tui"]

# This feature enables some nightly flags that make it more clear what structs/methods are available in each feature
nightly-doc = []

[dev-dependencies]
futures-util = { workspace = true }
tracing = { workspace = true }
Expand Down
23 changes: 11 additions & 12 deletions packages/dioxus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
// It's not required, but highly recommended. For example, UpperCamelCase components will not generate a warning.
#[component]
fn App() -> Element {
rsx!("hello world!"))
rsx!("hello world!")
}
```

Expand Down Expand Up @@ -97,13 +97,12 @@ If we want to omit the boilerplate of `cx.render`, we can simply pass in
render nodes in match statements.

```rust, ignore
#[component[
#[component]
fn Example() -> Element {
// both of these are equivalent
rsx!("hello world"))
rsx!("hello world");
rsx!("hello world!")
rsx!("hello world!");
}
```

Expand All @@ -127,7 +126,7 @@ fn App() -> Element {
))
}
))
)
}
```

Expand All @@ -147,7 +146,7 @@ fn App() -> Element {
title: "My App",
color: "red",
}
))
)
}
```

Expand All @@ -169,7 +168,7 @@ fn Header(cx: Scope<HeaderProps>) -> Element {
background_color: "{cx.props.color}"
h1 { "{cx.props.title}" }
}
))
)
}
```

Expand All @@ -184,7 +183,7 @@ fn Header(title: String, color: String) -> Element {
background_color: "{color}"
h1 { "{title}" }
}
))
)
}
```

Expand All @@ -201,13 +200,13 @@ struct HeaderProps<'a> {
}
#[component]
fn Header(props: HeaderProps -> Element {
fn Header(props: HeaderProps) -> Element {
rsx!(
div {
background_color: "{cx.props.color}"
h1 { "{cx.props.title}" }
}
))
)
}
```

Expand Down Expand Up @@ -299,7 +298,7 @@ fn App() -> Element {
div { "Count: {count}" }
button { onclick: move |_| count.set(count + 1), "Increment" }
button { onclick: move |_| count.set(count - 1), "Decrement" }
))
)
}
```

Expand Down
9 changes: 9 additions & 0 deletions packages/dioxus/src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl LaunchBuilder {

/// Launch your web application.
#[cfg(feature = "web")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "web")))]
pub fn web() -> LaunchBuilder<dioxus_web::Config, UnsendContext> {
LaunchBuilder {
launch_fn: dioxus_web::launch::launch,
Expand All @@ -48,6 +49,7 @@ impl LaunchBuilder {

/// Launch your desktop application.
#[cfg(feature = "desktop")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "desktop")))]
pub fn desktop() -> LaunchBuilder<dioxus_desktop::Config, UnsendContext> {
LaunchBuilder {
launch_fn: dioxus_desktop::launch::launch,
Expand All @@ -58,6 +60,7 @@ impl LaunchBuilder {

/// Launch your fullstack application.
#[cfg(feature = "fullstack")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "fullstack")))]
pub fn fullstack() -> LaunchBuilder<dioxus_fullstack::Config, SendContext> {
LaunchBuilder {
launch_fn: dioxus_fullstack::launch::launch,
Expand All @@ -68,6 +71,7 @@ impl LaunchBuilder {

/// Launch your fullstack application.
#[cfg(feature = "mobile")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "mobile")))]
pub fn mobile() -> LaunchBuilder<dioxus_mobile::Config, UnsendContext> {
LaunchBuilder {
launch_fn: dioxus_mobile::launch::launch,
Expand All @@ -77,6 +81,7 @@ impl LaunchBuilder {
}

#[cfg(feature = "tui")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "tui")))]
/// Launch your tui application
pub fn tui() -> LaunchBuilder<dioxus_tui::Config, UnsendContext> {
LaunchBuilder {
Expand Down Expand Up @@ -209,24 +214,28 @@ pub fn launch(app: fn() -> Element) {
}

#[cfg(feature = "web")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "web")))]
/// Launch your web application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_web(app: fn() -> Element) {
LaunchBuilder::web().launch(app)
}

#[cfg(feature = "desktop")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "desktop")))]
/// Launch your desktop application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_desktop(app: fn() -> Element) {
LaunchBuilder::desktop().launch(app)
}

#[cfg(feature = "fullstack")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "fullstack")))]
/// Launch your fullstack application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_fullstack(app: fn() -> Element) {
LaunchBuilder::fullstack().launch(app)
}

#[cfg(feature = "tui")]
#[cfg_attr(any(docsrs, feature = "nightly-doc"), doc(cfg(feature = "tui")))]
/// Launch your tui application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_tui(app: fn() -> Element) {
LaunchBuilder::tui().launch(app)
Expand Down
Loading

0 comments on commit f4651ce

Please sign in to comment.