Skip to content

Commit

Permalink
Generate the doc for bxl utils functions
Browse files Browse the repository at this point in the history
Summary:
Generate the doc for bxl utils functions

With this, user can search the utils functions on our doc page.
With future adding functions, it will also appear here.

We can also add the docs for build rule's util functions

 {F1974926634}

Reviewed By: JakobDegen

Differential Revision: D69126057

fbshipit-source-id: 5a29e1121e16105d5a8001386815f97afa566d51
  • Loading branch information
Nero5023 authored and facebook-github-bot committed Feb 5, 2025
1 parent 13e1402 commit 8728b74
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions starlark/src/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ pub struct DocModule {
pub members: SmallMap<String, DocItem>,
}

impl DocModule {
pub fn filter<P>(self, mut predicate: P) -> Self
where
P: FnMut(&(String, DocItem)) -> bool,
{
let members = self
.members
.into_iter()
.filter(|member| predicate(member))
.collect();

Self {
docs: self.docs,
members,
}
}
}

/// Documents a single function.
#[derive(Debug, Clone, PartialEq, Default, Allocative)]
pub struct DocFunction {
Expand Down
6 changes: 5 additions & 1 deletion starlark/src/environment/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ impl FrozenModule {
pub fn documentation(&self) -> DocModule {
let members = self
.all_items()
.filter(|n| Module::default_visibility(n.0.as_str()) == Visibility::Public)
.filter(|n| {
// We only want to show public symbols in the documentation
self.get_any_visibility_option(n.0.as_str())
.map_or(false, |(_, vis)| vis == Visibility::Public)
})
// FIXME(JakobDegen): Throws out information
.map(|(k, v)| {
(
Expand Down

0 comments on commit 8728b74

Please sign in to comment.