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

Expose interface file paths when reading the workspace #72

Closed
wants to merge 1 commit into from

Conversation

SneakyPeet
Copy link

What?

Expose paths to interface files as part of the workspace.

polylith.clj.core.workspace-clj.interface/workspace-from-disk return data will now include a :paths field in the component interface data.

{:components 
 [{:interface 
   {:paths ["/full/path/to/interface.clj"]}}]}

polylith.clj.core.workspace.interface/enrich-workspace will add the same :paths field to the interface data

{:interfaces
 [{:path ["/full/path/to/interface.clj"]}]}

Why?

It will be handy to be able to generate documentation for the interfaces of a given workspace. I looked into adding metadata, doc-strings and attr-map as part of the interface definitions.

However due to the way poly tool currently reads files (using clojure.core/read) any metadata literals (^{}) defined does not get read and is not available for export. There are ways around this, but I doubt that it makes sense going through the effort to change how poly reads files.

Instead, if the paths to interfaces files are available on workspace level, anyone can use these paths as they see fit and integration with existing documentation tools become easier.

The code change footprint is also much smaller

Finally the workspace file is less bloated than it would be if metadata is added (or alternatively if extra code has to be written to toggle metadata on and off).

@SneakyPeet
Copy link
Author

@tengstrand I've been mulling over this solution and I realise that it is just as easy to build the path from the actual ws data.

Also given #66 and the potential breaking changes, I'm not sure that this actually adds value (given that you can just build the paths).

So given the above I am going to close this PR for now. We can probably revisit it, but ultimately, sometimes the best code is no code :)

@SneakyPeet SneakyPeet closed this Feb 19, 2021
@tengstrand
Copy link
Collaborator

tengstrand commented Feb 19, 2021

@SneakyPeet My suggested solution is this:

  • Read metadata and add the :meta key for all definitions in the interface if :meta is passed in as an argument (e.g. "components:mycomponent:interface:definitions").
  • Add the attributes :is-interface and :sub-ns (if is an interface and a sub namespace) to :namespaces-src for each component (e.g. "components:mycomponent:namespaces-src").

This should make it easy to get the path for each definition, and also be a convenient way to extract metadata.
I also agree that the best code is no code! :-)

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.

2 participants