-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(doc): reuse solar sema compiler #11980
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
Conversation
crates/doc/src/parser/item.rs
Outdated
// Remove extra indent from docs. | ||
self.code = code | ||
.lines() | ||
.map(|line| line.strip_prefix(" ").unwrap_or(line)) | ||
.collect::<Vec<_>>() | ||
.join("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that we should make this more robust.
what i'd like to see is the following logic:
- get the source code from beginning of line to
self.source.range().start
- strip the indentation of this source code (should be an empty string or just indentation) from all lines
function topLevel() public {
// this needs 1 indentation level, none should be removed
}
contract TopLevel {
function innerLevel() public {
// this has 2 ind, 1 needs to be removed
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the logic to remove only if starts with > 4 whitespaces (that is to proper format the free functions as in prev version), since we're going to remove solang anyways not sure if should spend more time on this, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it is fine as a temp workaround as we need to drop the solang dep anyways.
once we do that, we can do it properly
let's wait for @DaniPopes to have a look before we merge |
crates/doc/src/builder.rs
Outdated
let mut files = vec![]; | ||
|
||
// Read and parse source file | ||
if let Some(ast) = gcx.sources.iter().find(|source| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcx.get_ast_source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crates/doc/src/parser/item.rs
Outdated
self.code = code | ||
.lines() | ||
.map(|line| { | ||
if line.chars().take_while(|c| c.is_whitespace()).count() > 4 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just trim_start always
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what he did initially, but that's inaccurate.
see the reasoning here: #11980 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* fix(doc): reuse solar sema compiler * fix: include only fn sig in docs * proper format docs, remove extra indent & append ; at enf of fn * changes after review: use get_ast_source, strip prefix always
* fix(doc): reuse solar sema compiler (#11980) * fix(doc): reuse solar sema compiler * fix: include only fn sig in docs * proper format docs, remove extra indent & append ; at enf of fn * changes after review: use get_ast_source, strip prefix always * fix(chisel): disable compiler optimizations (#11990) Add --ir-minimum like in `forge coverage`, and disable optimizations since we rely on source maps to inspect expressions. --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
Motivation
func.loc_prototype
no body) + add;
at the end of sig to match prev behaviorSolution
PR Checklist