Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] #177

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

[wip] #177

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

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

8 changes: 3 additions & 5 deletions compiler/documenter/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::{
node::{Attributable, Element},
};
use hir::DeclarationIndex;
use hir_format::{ComponentExt, Display, SessionExt};
use hir_format::{Display, SessionExt as _};
use joinery::JoinableIterator;
use session::Session;
use std::fmt::Write;
Expand Down Expand Up @@ -257,10 +257,8 @@ impl<'a> Formatter<'a> {
}

fn module_url_fragment(&self, index: DeclarationIndex) -> String {
let component = self.session.component_of(index);

let mut segments = component.local_index_to_path_segments(index.local_unchecked());
segments.push_front(component.name().into_inner());
let mut segments = self.session.index_to_path_segments(index);
segments.push_front(self.session.component_of(index).name().into_inner());

format!(
"{}{}/index.html",
Expand Down
18 changes: 6 additions & 12 deletions compiler/documenter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ use crossbeam::thread::Scope;
use derivation::Elements;
use diagnostics::error::Result;
use hir::{Attribute, AttributeName, Attributes, BareAttribute};
use hir_format::ComponentExt;
use hir_format::SessionExt;
use joinery::JoinableIterator;
use lexer::word::Word;
use node::{Attributable, Document, Element, Node, VoidElement};
use session::{
component::{DeclarationIndexExt, IdentifierExt},
package::{ManifestPath, Package},
Context, Session, OUTPUT_FOLDER_NAME,
};
Expand Down Expand Up @@ -203,11 +202,7 @@ impl<'a, 'scope> Documenter<'a, 'scope> {
// incorrect on top of that!)
let path = self
.session
.component()
.local_index_with_root_to_extern_path(
index.local(self.session).unwrap(),
component_name.to_owned(),
);
.index_with_root_to_extern_path(index, component_name.to_owned());

write!(
search_index,
Expand Down Expand Up @@ -534,10 +529,10 @@ impl<'a, 'scope> Documenter<'a, 'scope> {
}

fn add_module_page(&self, module: &hir::Module, attributes: &Attributes) -> Page {
let index = module.binder.local_declaration_index(self.session).unwrap();
let index = module.binder.declaration_index().unwrap();
let component_name = self.session.component().name();

let mut segments = self.session.component().local_index_to_path_segments(index);
let mut segments = self.session.index_to_path_segments(index);
segments.push_front(component_name.into_inner());
let page_depth = segments.len();
let url_prefix = format!("./{}", "../".repeat(page_depth));
Expand Down Expand Up @@ -571,7 +566,7 @@ impl<'a, 'scope> Documenter<'a, 'scope> {
{
let mut heading = Element::new("h1");

heading.add_child(match index == self.session.component().root_local() {
heading.add_child(match index.is_root() {
true => "Component",
false => "Module",
});
Expand Down Expand Up @@ -613,8 +608,7 @@ impl<'a, 'scope> Documenter<'a, 'scope> {

let title = self
.session
.component()
.local_index_with_root_to_extern_path(index, component_name.to_string());
.index_with_root_to_extern_path(index, component_name.to_string());

Page {
path: segments
Expand Down
1 change: 0 additions & 1 deletion compiler/driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ derivation = { path = "../../project/library/derivation" }
diagnostics = { path = "../diagnostics" }
documenter = { path = "../documenter" }
hir_format = { path = "../hir_format" }
index_map = { path = "../../project/library/index_map" }
lexer = { path = "../lexer" }
lo_ast = { path = "../lo_ast" }
lowerer = { path = "../lowerer" }
Expand Down
17 changes: 9 additions & 8 deletions compiler/driver/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ use utility::{
paint::{paint_to_string, AnsiColor, ColorChoice},
};

// @Task update the color scheme of the `-Zhelp` output from clap-3-style to clap-4-style
// i.e. from upper-case section titles and the use of yellow & green to
// bold & underlined section titles and the use of bold letters

pub(crate) fn arguments() -> Result<(Command, GlobalOptions)> {
let short_version = format!(
"{} ({} {})",
Expand Down Expand Up @@ -134,7 +130,7 @@ pub(crate) fn arguments() -> Result<(Command, GlobalOptions)> {
.action(ArgAction::Append)
.help("Set an unstable option. See ‘-Z help’ for details");

// @Task use `try_get_matches` (no real block, just def an error type and smh exit with code 2 instead of 1 on error)
// @Task use `try_get_matches` (just define an error type and smh exit with code 2 instead of 1 on error)
let matches = clap::Command::new("lushui")
.bin_name("lushui")
.version(short_version)
Expand Down Expand Up @@ -238,6 +234,8 @@ pub(crate) fn arguments() -> Result<(Command, GlobalOptions)> {
.required(true)
.help("The path to the Recnot file"),
),
clap::Command::new(subcommand::TREE)
.about("Display a tree visualization of a dependency graph"),
])
.get_matches();

Expand Down Expand Up @@ -341,6 +339,7 @@ pub(crate) fn arguments() -> Result<(Command, GlobalOptions)> {
(subcommand::RECNOT, matches) => Command::Recnot {
path: matches.get_one(argument::PATH).cloned().unwrap(),
},
(subcommand::TREE, _matches) => Command::Tree,
_ => unreachable!(),
};

Expand All @@ -359,6 +358,7 @@ mod subcommand {
pub(super) const RUN: &str = "run";
#[cfg(feature = "lsp")]
pub(super) const SERVE: &str = "serve";
pub(super) const TREE: &str = "tree";
}

mod argument {
Expand Down Expand Up @@ -396,16 +396,17 @@ pub(crate) enum Command {
mode: BuildMode,
options: FileBuildOptions,
},
#[cfg(feature = "lsp")]
Serve,
Explain,
CreatePackage {
mode: PackageCreationMode,
options: PackageCreationOptions,
},
Explain,
Recnot {
path: PathBuf,
},
#[cfg(feature = "lsp")]
Serve,
Tree,
}

pub(crate) struct GlobalOptions {
Expand Down
Loading