-
Notifications
You must be signed in to change notification settings - Fork 15
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 #237 from moonbitlang/add-packages-json-for-moondoc
add --packages-json for moondoc
- Loading branch information
Showing
10 changed files
with
111 additions
and
11 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
// For inquiries, you can contact us via e-mail at [email protected]. | ||
|
||
use anyhow::bail; | ||
use moonbuild::dry_run::print_commands; | ||
use mooncake::pkg::sync::auto_sync; | ||
use moonutil::common::{ | ||
read_module_desc_file_in_dir, CargoPathExt, FileLock, MoonbuildOpt, MooncOpt, RunMode, | ||
|
@@ -64,16 +65,6 @@ pub fn run_doc(cli: UniversalFlags, cmd: DocSubcommand) -> anyhow::Result<i32> { | |
let bind = cmd.bind; | ||
let port = cmd.port; | ||
|
||
if cli.dry_run { | ||
println!( | ||
"moondoc {} -o {}{}", | ||
source_dir.display(), | ||
static_dir.display(), | ||
if serve { " -serve-mode" } else { "" } | ||
); | ||
return Ok(0); | ||
} | ||
|
||
let mod_desc = read_module_desc_file_in_dir(&source_dir)?; | ||
|
||
let mut moonc_opt = MooncOpt::default(); | ||
|
@@ -105,7 +96,6 @@ pub fn run_doc(cli: UniversalFlags, cmd: DocSubcommand) -> anyhow::Result<i32> { | |
&moonc_opt, | ||
&moonbuild_opt, | ||
)?; | ||
moonbuild::entry::run_check(&moonc_opt, &moonbuild_opt, &module)?; | ||
|
||
let mut args = vec![ | ||
source_dir.display().to_string(), | ||
|
@@ -115,10 +105,22 @@ pub fn run_doc(cli: UniversalFlags, cmd: DocSubcommand) -> anyhow::Result<i32> { | |
moonutil::moon_dir::core_bundle(moonc_opt.link_opt.target_backend) | ||
.display() | ||
.to_string(), | ||
"-packages-json".to_string(), | ||
moonbuild_opt | ||
.target_dir | ||
.join("packages.json") | ||
.display() | ||
.to_string(), | ||
]; | ||
if serve { | ||
args.push("-serve-mode".to_string()) | ||
} | ||
if cli.dry_run { | ||
print_commands(&module, &moonc_opt, &moonbuild_opt)?; | ||
println!("moondoc {}", args.join(" ")); | ||
return Ok(0); | ||
} | ||
moonbuild::entry::run_check(&moonc_opt, &moonbuild_opt, &module)?; | ||
let output = std::process::Command::new("moondoc").args(&args).output()?; | ||
if output.status.code().unwrap() != 0 { | ||
eprintln!("{}", String::from_utf8_lossy(&output.stderr)); | ||
|
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 @@ | ||
target/ | ||
.mooncakes/ |
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 @@ | ||
# username/hello |
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,10 @@ | ||
{ | ||
"name": "username/hello", | ||
"version": "0.1.0", | ||
"readme": "README.md", | ||
"repository": "", | ||
"license": "", | ||
"keywords": [], | ||
"description": "", | ||
"source": "src" | ||
} |
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,3 @@ | ||
pub fn hello() -> String { | ||
"Hello, world!" | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/moon/tests/test_cases/moon_doc.in/src/lib/hello_test.mbt
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,5 @@ | ||
test "hello" { | ||
if @lib.hello() != "Hello, world!" { | ||
fail!("@lib.hello() != \"Hello, world!\"") | ||
} | ||
} |
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 @@ | ||
{} |
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,3 @@ | ||
fn main { | ||
println(@lib.hello()) | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/moon/tests/test_cases/moon_doc.in/src/main/moon.pkg.json
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,6 @@ | ||
{ | ||
"is-main": true, | ||
"import": [ | ||
"username/hello/lib" | ||
] | ||
} |