-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
external_package_names(topology)
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name = "PlutoDependencyExplorer" | |
uuid = "72656b73-756c-7461-726b-72656b6b696b" | ||
license = "MIT" | ||
authors = ["Paul Berg <[email protected]>", "Fons van der Plas <[email protected]>"] | ||
version = "1.1.0" | ||
version = "1.2.0" | ||
|
||
[deps] | ||
ExpressionExplorer = "21656369-7473-754a-2065-74616d696c43" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ExpressionExplorer | ||
|
||
""" | ||
```julia | ||
external_package_names(topology::NotebookTopology)::Set{Symbol} | ||
``` | ||
Get the set of package names that are imported by any cell in the notebook. This considers all `using` and `import` calls. | ||
""" | ||
function ExpressionExplorer.external_package_names(topology::NotebookTopology)::Set{Symbol} | ||
union!(Set{Symbol}(), ExpressionExplorer.external_package_names.(c.module_usings_imports for c in values(topology.codes))...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Test | ||
import PlutoDependencyExplorer as PDE | ||
import PlutoDependencyExplorer.ExpressionExplorer | ||
|
||
@testset "external_package_names" begin | ||
struct SimpleCell <: PDE.AbstractCell | ||
code | ||
end | ||
|
||
notebook = SimpleCell.([ | ||
"using Plots, Example.Something" | ||
"""begin | ||
import .Yoooo | ||
import Sick: nice | ||
end""" | ||
":(import Nonono)" | ||
]); | ||
|
||
empty_topology = PDE.NotebookTopology{SimpleCell}(); | ||
|
||
topology = PDE.updated_topology( | ||
empty_topology, | ||
notebook, notebook; | ||
get_code_str = c -> c.code, | ||
get_code_expr = c -> Meta.parse(c.code), | ||
); | ||
|
||
@test ExpressionExplorer.external_package_names(topology) == Set([:Plots, :Example, :Sick]) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters