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

Show dependencies on a functional level #291

Open
tengstrand opened this issue Mar 12, 2023 · 2 comments
Open

Show dependencies on a functional level #291

tengstrand opened this issue Mar 12, 2023 · 2 comments
Labels
improvement Not a bug but an improvement to overall user experience

Comments

@tengstrand
Copy link
Collaborator

tengstrand commented Mar 12, 2023

We can show dependencies for a brick by giving a brick name to the deps command:

poly deps brick:git

  used by        <  git  >  uses
  -------------             ----
  change                    sh
  command                   util
  creator
  workspace-clj
  ws-file

Sometimes we are interested in showing from which namespace a call is made and/or which functions that are called.
A solution could be to also pass in :fn and list all the function calls:

poly deps brick:git :fn

  git uses
  ------------------------------------------------
  git.core > sh.interface/execute-ignore-exception
  git.core > sh.interface/execute-with-return
  git.tag > sh.interfrace/execute
  git.tag > util.interface.str/skip-until
  git.tag > util.interface.str/take-until)

  git is used by
  ----------------------------------------------------------------------------
  change.core > git.interface/diff
  change.core > git.interface/diff-command
  change.core > git.interface/is-git-repo?
  change.core > git.interface/sha
  command.cmd-validator.create.cmd-validator.core > git.interface/is-git-repo?
  creator.brick > git.interface/add
  creator.project > git.interface/add
  creator.workspace > git.interface/current-branch
  creator.workspace > git.interface/init
  creator.workspace > git.interface/is-git-repo?
  creator.workspace > git.interface/latest-polylith-sha
  creator.workspace-test (t) > git.interface/latest-polylith-sha
  workspace-clj.core > git.interface/current-branch
  workspace-clj.core > git.interface/git-branch
  workspace-clj.core > git.interface/is-git-repo?
  workspace-clj.core > git.interface/latest-polylith-sha
  workspace-clj.core > git.interface/repo
  workspace-clj.core > git.interface/root-dir
  workspace-clj.core > git.interface/sha
  ws-file.from-1-to-2 > git/branch
  ws-file.from-1-to-2 > git/repo

If passing in :project we should show which concrete component that is called.

If the brick is not given, we should list all calls for the entire workspace.

It should be possible to extend this functionality to also list library calls.

@tengstrand tengstrand added the improvement Not a bug but an improvement to overall user experience label Mar 13, 2023
@MrEbbinghaus
Copy link

Just stumbled over this issue.

A while ago, I wrote a script (~100 loc) that generates a .dot file from all symbols in my project.

The limited analysis output of clj-kondo is really useful for this:
https://github.com/clj-kondo/clj-kondo/tree/master/analysis#limited-analysis

From that, you can use :var-definitions (nodes) and :var-usages (edges) to get what you want.

There are a bunch of examples further down that file: https://github.com/clj-kondo/clj-kondo/tree/master/analysis#example-tools

...
"decide.server-components.pathom/spec-plugin"   [label="decide.server-components.pathom/spec-plugin",shape=rectangle,fontcolor=black,group="decide.server-components.pathom",color="#40c9cd"];
"decide.ui.meta/ui-meta"                        [label="decide.ui.meta/ui-meta",shape=rectangle,fontcolor=black,group="decide.ui.meta",color="#73a0d4"];
"decide.ui.components.snackbar/create-snackbar" [label="decide.ui.components.snackbar/create-snackbar",shape=rectangle,fontcolor=black,group="decide.ui.components.snackbar",color="#635539"];

subgraph "decide.models.opinion.api" {
   "decide.models.opinion.api/set-opinion" -> "decide.models.opinion.api/conj-opinion-to-opinions";
   "decide.models.opinion.api/set-opinion" -> "decide.models.opinion.api/update-vote-fields";
   "decide.models.opinion.api/conj-opinion-to-opinions" -> "decide.models.opinion.api/remove-opinion-of-user";
   "decide.models.opinion.api/remove-opinion-of-user" -> "decide.models.opinion.api/user's-opinion?";
   "decide.models.opinion.api/de-favorite-all" -> "decide.models.opinion.api/set-opinion";
   "decide.models.opinion.api/de-favorite-all" -> "decide.models.opinion/favorite?";
   "decide.models.opinion.api/de-favorite-all" -> "decide.models.opinion.api/update-proposals";
   "decide.models.opinion.api/add" -> "decide.models.process.database/->enter";
   ...
}

image

@tengstrand
Copy link
Collaborator Author

Thanks for this @MrEbbinghaus!

When the time comes to implement this issue, we should definitely consider using these tools!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Not a bug but an improvement to overall user experience
Projects
None yet
Development

No branches or pull requests

2 participants