Skip to content

navigate to bookdown xrefs in omni-search - #7302

Merged
kevinushey merged 8 commits into
masterfrom
feature/bookdown-omni-search
Jul 20, 2020
Merged

kevinushey merged 8 commits into
masterfrom
feature/bookdown-omni-search

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

This PR makes it possible to navigate to sections, figures and tables within a bookdown project via the fuzzy finder.

Screen Shot 2020-07-07 at 4 08 32 PM

Some questions worth answering before final merge:

  1. What should we display for sections / figures / tables? The caption? The ID? Some combination?
  2. Is it worth refining the search for the associated title string in source-only XRef navigation?

@kevinushey
kevinushey requested a review from jjallaire July 8, 2020 18:38
}

// figure out appropriate source item type
SourceItem::Type sourceType = SourceItem::None;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@jjallaire: are there any other reference types I should handle here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kevinushey
kevinushey force-pushed the feature/bookdown-omni-search branch from cfc6a8b to fc8f15f Compare July 8, 2020 21:47

@jjallaire jjallaire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like the right approach, see a few comments about treatment for ids/titles in the find UI + some additional types to look out for.

EnumValue = 5,
Namespace = 6
Namespace = 6,
Section = 7,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's also equations and theorems (although the latter obscure enough that we probably don't need navigation for it).

EnumValue = 5,
Namespace = 6
Namespace = 6,
Section = 7,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to distinguish between heading levels here? (Hadley had asked for distinguishing headings levels in xref completions b/c it's helpful context). Paul could do separate icons for H1-H6.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Even just h1 vs h2 vs everything else would be useful

}

// figure out appropriate source item type
SourceItem::Type sourceType = SourceItem::None;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

}

// form appropriate text for display
std::string displayText = title;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm torn as to whether we should be showing IDs here, at least for figures, tables, and equations -- as that's the 'identifier' that's being searched for (i.e. for functions we don't show the roxygen title if available we show the name of the function). I've also seen that figure and table captions can get quite long (even multiple sentences) and I think the id would be a better mental "bookmark' in the case cases.

For section I can see the argument that we should use the actual title (since the id is typically algorithmically derived from the title).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about both, like title (#id) ? Or is that likely to be too long?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it will be too long (a section title would typically be ~ 10-30 characters which is already over the effective limit for the UI).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If we think displaying the ID is necessary we could truncate the section title and always append the ID.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd say try it without, and then if it's frustrating we figure out how to add it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think no ID for sections/headers to start with is fine, but we definitely should use the IDs for figures, tables, and equations. In those cases that's the actual "symbol" they are navigating to (it's the chunk label).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, to re-iterate: do we want to be able to search based on the contents of the caption (e.g. for a figure), or only based on the figure ID?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should search based on contents, but we should show the id in the list

return target;

// nothing to do if the query doesn't have ':'
int colonIndex = query.indexOf(":");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps it's accounted for elsewhere, but do we want to have fig:, tab:, etc. filter on xref type?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would be nice but it's not very discoverable, so hard to know if people would ever use it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's true. Probably not worth it then.

@kevinushey
kevinushey force-pushed the feature/bookdown-omni-search branch from 6043dee to b2a0357 Compare July 10, 2020 21:42
@kevinushey
kevinushey merged commit 0002b92 into master Jul 20, 2020
@kevinushey

Copy link
Copy Markdown
Collaborator Author

Going to merge this now (to avoid future merge conflicts); we can tweak the display post-merge.

@valerie-rstudio
valerie-rstudio deleted the feature/bookdown-omni-search branch January 21, 2022 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants