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

Documentation panel redesign #7372

Merged
merged 28 commits into from
Aug 15, 2023
Merged

Conversation

vitvakatu
Copy link
Contributor

Pull Request Description

Based on #7350

Closes #7356

  • Documentation parser now supports two new DocSection types:
    • List is a better representation of unordered lists anywhere in the text.
    • Arguments, a list starting with the Arguments: keyword. Each item in the list is split into argument names and descriptions, and we use this information to highlight argument names in the documentation.
      I'm not confident with my changes to the doc parser, especially due to the fact there were exactly zero tests for it.
  • Small adjustments to the documentation CSS. It now looks much closer to the design, though not ideal. In particular, paddings are different now, and no topmost headers are displayed. (as they are replaced with the breadcrumbs in the new design) I also used fixed sizes like 4px instead of 0.25rem to simplify matching with the design. I believe it is the way as we want the most accurate translation from Figma, even though it is generally not the best practice.
  • Improvements for tags styles. The proper implementation (with different colors, limited count, custom per-tag formatting, ... button...) will require more effort.
  • Breadcrumbs are in almost proper position now. The exact positioning should be done after updating them to the new design.
  • Added a missed support for code tags in the documentation. Now text emphasized with backticks has a separate background color.
2023-07-23.17-34-13.mp4

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

Comment on lines 288 to 294
/// No documentation is available for the entry.
#[derive(Debug, Clone, CloneRef, PartialEq)]
#[derive(Debug, Clone, Copy, CloneRef, PartialEq)]
#[allow(missing_docs)]
pub enum Placeholder {
/// Documentation is empty.
NoDocumentation,
/// Documentation for the Virtual Component group.
VirtualComponentGroup { name: ImString },
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could make it a structure? Or it's not needed anymore?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed anymore and I removed it.

self.breadcrumbs.set_xy(Vector2(0.0, size.y + 36.0));
self.breadcrumbs.frp().set_size(Vector2(size.x, 32.0));
}

/// Display the documentation and scroll to the qualified name if needed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems outdated (already before this change)

Comment on lines 196 to 210
let size = Vector2(style.width * width_factor, style.height);
self.overlay.set_size(size);
let dom_size = Vector2(size.x, size.y - style.breadcrumbs_height);
self.dom.set_dom_size(dom_size);
self.dom.set_xy(dom_size / 2.0);

self.background.set_color(style.background);
self.background.set_corner_radius(style.corner_radius);
self.background.set_size(size);

self.overlay.set_corner_radius(style.corner_radius);
self.outer_dom.set_style_or_warn("border-radius", format!("{}px", style.corner_radius));
self.inner_dom.set_style_or_warn("border-radius", format!("{}px", style.corner_radius));
let bg_color = style.background.to_javascript_string();
self.outer_dom.set_style_or_warn("background-color", bg_color);
self.dom.set_style_or_warn("border-radius", format!("{}px", style.corner_radius));

self.breadcrumbs.set_xy(Vector2(0.0, size.y));
self.breadcrumbs.frp().set_size(Vector2(size.x, style.breadcrumbs_height));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how these lines are organized--it is partially by the component, but some of the corner_radius configuration has its own section?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved them to be organised by component.

@@ -155,6 +186,9 @@ impl<L> TokenConsumer<L> for DocSectionCollector {
fn enter_keyed_section(&mut self, header: Span<'_, L>) {
self.finish_section();
let key = header.to_string();
if key.to_lowercase() == "arguments" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if key.to_lowercase() == "arguments" {
if key.eq_ignore_ascii_case("Arguments") {

We process a lot of documentation; it's important to avoid allocations when we can.

Comment on lines 147 to 150
Some(DocSection::Tag { .. })
| Some(DocSection::List { .. })
| Some(DocSection::Arguments { .. })
| None => self.sections.push(DocSection::Paragraph { body: text }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing the empty Paragraph between the List and the "Example:" section in the new test. The empty paragraph is not needed; the newlines between sections are implicit.

Suggested change
Some(DocSection::Tag { .. })
| Some(DocSection::List { .. })
| Some(DocSection::Arguments { .. })
| None => self.sections.push(DocSection::Paragraph { body: text }),
Some(DocSection::List { .. }) | Some(DocSection::Arguments { .. }) => (),
Some(DocSection::Tag { .. }) | None => self.sections.push(DocSection::Paragraph { body: text }),

ScopeType::List => self.current_body.push_str("</ul>"),
ScopeType::ListItem => (),
ScopeType::List => {
let items = mem::take(&mut self.current_list);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives away our buffer. If we take it, we need log(size) allocations per list. If we iterate/clone it and then clear it, we only need one allocation per List.

}
}
ScopeType::ListItem => {
self.current_list.push(mem::take(&mut self.current_body));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.current_list.push(mem::take(&mut self.current_body));
self.current_list.push(self.current_body.drain(..).collect());

}].to_vec()
},
List { items: ["List item 1".into(), "List item 2".into(), "List item 3".into()].to_vec() },
Paragraph { body: "".into() },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spurious, see above.

Base automatically changed from wip/vitvakatu/cb-panel to develop July 31, 2023 15:33
Copy link
Contributor

@somebody1234 somebody1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same (automatic) package-lock.json change as in some other PRs.
when merging with develop, this change should go away, because said change has been merged into develop:

"enso-chat": "git://github.com/enso-org/enso-bot",

@MichaelMauderer MichaelMauderer linked an issue Aug 1, 2023 that may be closed by this pull request
@MichaelMauderer MichaelMauderer force-pushed the wip/vitvakatu/doc-panel-redesign branch from 4c2beed to 6658bb8 Compare August 3, 2023 09:58
Added padding_x and padding_y to hardcoded theme's breadcrumb settings to ensure consistent padding. Also, these padding settings and breadcrumb_height are now used directly in the Style structure, eliminating hardcoded values in the view documentation.
@Frizi
Copy link
Contributor

Frizi commented Aug 8, 2023

QA Status: 🔴

Overall it looks good, but there are still some minor rendering issues in some edge cases. It looks like some of them are caused by the documentation not having a consistent syntax in a few places.

  1. Some methods have truncated argument lists. The documentation is not properly formatted, such that the argument list is missing a colon after the argument name. Though I think that it should be displayed in some way anyway. Instead, now is displayed as a list with empty items.
Zrzut ekranu 2023-08-08 141610
  1. We are currently displaying all tags. I don't think that ICON tag should really be shown. We already display the icon itself after all. Though this is not a big issue and might be addressed later if needed.
Zrzut ekranu 2023-08-08 141725
  1. The selection behaves strangely right after typing. There are two distinct selection indicators (do we still need that?), and they point to different entries. Additionally, the list is scrolled up, such that the actual selected entry is partially outside the view.

EDIT: I think this was a separate issue that is already fixed on develop (hence I have only noticed it in this branch). Updating the branch should resolve it.

cb-strange-selection.mp4

@vitvakatu
Copy link
Contributor Author

I'll take it from here, thanks for testing.

@vitvakatu
Copy link
Contributor Author

@Frizi I fixed both issues.

  1. Now we correctly parse space-separated arguments.
  2. Icon tag is now ignored in the documentation.

Could you retest?

@xvcgreg
Copy link

xvcgreg commented Aug 11, 2023

@Frizi can you retest it?

@Frizi
Copy link
Contributor

Frizi commented Aug 11, 2023

QA Status: 🟡

The above issues has been fixed, but i've noticed that invalid behavior of the documentation show/hide action has been reintroduced. The content of the panel should not be reflowed on every frame of the animation. Instead, it should be clipped to fit the animated background size, without acutally changing the content width of underlying DOM element.

See point 2. in #7350 (comment)

No other issues spotted, so once show/hide is fixed it's good to go.

@vitvakatu vitvakatu added CI: Ready to merge This PR is eligible for automatic merge CI: No changelog needed Do not require a changelog entry for this PR. labels Aug 14, 2023
@vitvakatu vitvakatu merged commit 02ba9a1 into develop Aug 15, 2023
27 of 29 checks passed
@vitvakatu vitvakatu deleted the wip/vitvakatu/doc-panel-redesign branch August 15, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improved documentation view, as in the design.
7 participants