Skip to content

Commit

Permalink
refactor: move doc server to forge crate
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Nov 15, 2023
1 parent 3eb9ac3 commit f71dc60
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 34 deletions.
9 changes: 4 additions & 5 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions crates/cast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ vergen = { version = "8", default-features = false, features = ["build", "git",

[dependencies]
# lib
foundry-block-explorers = { workspace = true }
foundry-block-explorers.workspace = true
foundry-common.workspace = true
foundry-compilers = { workspace = true, default-features = false }
foundry-compilers.workspace = true
foundry-config.workspace = true
foundry-evm.workspace = true
foundry-utils.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository.workspace = true

[dependencies]
foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] }
foundry-compilers = { workspace = true, features = ["async", "svm-solc"] }
foundry-compilers = { workspace = true, features = ["svm-solc"] }

alloy-chains = { workspace = true, features = ["serde"] }
alloy-primitives = { workspace = true, features = ["serde"] }
Expand Down
8 changes: 1 addition & 7 deletions crates/doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository.workspace = true

[dependencies]
forge-fmt.workspace = true
foundry-compilers = { workspace = true, features = ["async"] }
foundry-compilers.workspace = true
foundry-config.workspace = true
foundry-utils.workspace = true

Expand All @@ -29,11 +29,5 @@ serde_json.workspace = true
serde.workspace = true
solang-parser.workspace = true
thiserror = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
toml.workspace = true
tracing.workspace = true

axum = { workspace = true, features = ["ws"] }
hyper.workspace = true
tower-http = { workspace = true, features = ["fs"] }
opener = "0.6"
23 changes: 8 additions & 15 deletions crates/doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,22 @@
extern crate tracing;

mod builder;
mod document;
mod helpers;
mod parser;
mod preprocessor;
mod server;
mod writer;

/// The documentation builder.
pub use builder::DocBuilder;

/// The documentation server.
pub use server::Server;

/// The document output.
mod document;
pub use document::Document;

/// Solidity parser and related output items.
mod helpers;

mod parser;
pub use parser::{
error, Comment, CommentTag, Comments, CommentsRef, ParseItem, ParseSource, Parser,
};

/// Preprocessors.
mod preprocessor;
pub use preprocessor::*;

/// Traits for formatting items into doc output.
mod writer;
pub use writer::{AsDoc, AsDocResult, BufWriter, Markdown};

pub use mdbook;
6 changes: 6 additions & 0 deletions crates/forge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ thiserror = "1"
tokio = { version = "1", features = ["time"] }
watchexec = "2"

# doc server
axum = { workspace = true, features = ["ws"] }
hyper.workspace = true
tower-http = { workspace = true, features = ["fs"] }
opener = "0.6"

[dev-dependencies]
anvil.workspace = true
foundry-test-utils.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use clap::{Parser, ValueHint};
use eyre::Result;
use forge_doc::{ContractInheritance, Deployments, DocBuilder, GitSource, Inheritdoc, Server};
use forge_doc::{ContractInheritance, Deployments, DocBuilder, GitSource, Inheritdoc};
use foundry_cli::opts::GH_REPO_PREFIX_REGEX;
use foundry_config::{find_project_root_path, load_config_with_root};
use std::{path::PathBuf, process::Command};

mod server;
use server::Server;

#[derive(Debug, Clone, Parser)]
pub struct DocArgs {
/// The project's root path.
Expand Down Expand Up @@ -33,8 +36,8 @@ pub struct DocArgs {
#[clap(long, short)]
serve: bool,

/// Open the documentation in the browser.
#[clap(long)]
/// Open the documentation in a browser after serving.
#[clap(long, requires = "serve")]
open: bool,

/// Hostname for serving documentation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum::{routing::get_service, Router};
use mdbook::{utils::fs::get_404_output_file, MDBook};
use forge_doc::mdbook::{utils::fs::get_404_output_file, MDBook};
use std::{
net::{SocketAddr, ToSocketAddrs},
path::PathBuf,
Expand Down

0 comments on commit f71dc60

Please sign in to comment.