duct

2020-10-13T12:12:20.003600Z

Cross posting a question I asked here, as it’s relevant to the duct community too: https://clojurians.slack.com/archives/C52HVRVE1/p1602591007011000

kwrooijen 2020-10-14T08:45:02.024200Z

Shared my thoughts. I think we're pretty much on the same page but have different approaches. I'm not sure if the "finding project name" is viable, but it would keep the keydox.edn file simple (instead of having to add extra context / nesting)

1👀
2020-10-14T08:56:07.024500Z

Yeah seems like we’re very close to agreement here. I’ll repond on the issue to clarify a few more points though.

1👍
kwrooijen 2020-10-13T13:36:23.003800Z

I've been thinking about this as well. One solution could be an EDN file in the resources path. A keywords as keys and a map with "metadata". Similar to duct_hierarchy.edn, these files would be aggregated and merged together. Then you can use the metadata map for anything you want, e.g. docstrings

kwrooijen 2020-10-13T13:37:21.004Z

Not sure if this is actually a good solution though. Haven't decided to double down on the idea and create a project

2020-10-13T13:51:20.004200Z

:thinking_face: interesting I hadn’t really considered that option, but now you mention it, it is quite compelling. Though not sure why I didn’t think about this as we already do something similar in a different tool we built for deployment. I agree if we were to do it aggregating them like duct_hierarchy.edn would be essential. Forgetting the inputs for a minute, I was thinking there are essentially three levels of documentation requirements. One is providing a means to document common patterns for blocks of config… i.e. task/use-case oriented rather than at a component level. e.g. for us to configure one auth0 flow over another often requires choosing between several distinct patterns of config, where each block exposes several components worth of edn. Then there is at the level of the individual component. And finally at the level of individual keys within a component i.e. to encourage a single meaning or definition of a key across component configs, essentially embracing the ideas of spec etc.

2020-10-13T13:59:10.004400Z

@kevin.van.rooijen: Ok well I’ve solved the hardest problem in computer science and with this approach, which is naming it… It should be called keydox, kinda like codox but for documenting keys 😁

kwrooijen 2020-10-13T14:00:14.004600Z

haha sounds like a pretty good name. And it's available

kwrooijen 2020-10-13T14:00:50.004800Z

For the people familiar with codox, this would probably be clear what the intention is

2020-10-13T14:01:02.005Z

Indeed

2020-10-13T14:02:01.005200Z

Anyway… I’d be happy to help work on this too as best I can… and help work up a proposal for this if that would help.

kwrooijen 2020-10-13T14:02:44.005400Z

Also a nice thing would be if it's not just docstrings, but it can be any metadata. e.g. you could add a malli spec, or a describe the arguments. Using this metadata you can just build an interface around that

2020-10-13T14:03:14.005600Z

being open to extension is definitely a big bonus

kwrooijen 2020-10-13T14:03:49.005800Z

Sure, I can create a project and brainstorm ideas. It probably won't be too complex. Just an initial interface like a doc function, to set the standard

kwrooijen 2020-10-13T14:04:49.006Z

A standard has to be made if this is actually supposed to work, if people start using :doc :docstring :doc-string :description then that would be a waste

2020-10-13T14:05:40.006200Z

yeah agreed, you probably want to view it like RDF, like a metadata vocabulary, but for EDN

kwrooijen 2020-10-13T14:06:48.006500Z

Right

2020-10-13T14:10:12.006700Z

I was assuming supporting some level prose would be desirable too though. e.g. support for rendering code snippets etc Not necessarily saying it should support markdown. I think perhaps it needs to assume some hierarchy structure based on namespaces. i.e. maybe it would let you document at any namespace segment in :my.lib.some-component-ns/foo?

2020-10-13T14:11:09.007Z

e.g. :my.lib {:some :docs} would add docs to the parent of :my.lib.some-component-ns

2020-10-13T14:11:52.007200Z

not sure what all implications of that are, but it would I think be useful.

kwrooijen 2020-10-13T14:15:33.007400Z

hmm I'm not sure how I envision this hierarchy structure

kwrooijen 2020-10-13T14:16:22.007600Z

Feel free to add ideas https://github.com/kwrooijen/keydox/issues/1

2020-10-13T14:16:59.008Z

just thinking out loud; but will have a think and may try and work up an example

kwrooijen 2020-10-13T14:17:12.008200Z

Sounds good

2020-10-13T14:18:34.008400Z

One other thing I was assuming it would target integrant (and be duct compatible that way) rather than duct itself.

2020-10-13T14:18:44.008600Z

Not sure what your thinking is there?

kwrooijen 2020-10-13T14:18:49.008800Z

Another nice benefit is that you can actually document keys outside of the project owner's repo. e.g. you could create a duct-keydox repo and document all keys from the duct project. In case Weavejester doesn't want to add an EDN file to core

2020-10-13T14:19:07.009100Z

Yeah that is definitely a good idea

kwrooijen 2020-10-13T14:19:13.009300Z

I was thinking outside of Integrant / Duct actually

kwrooijen 2020-10-13T14:19:23.009500Z

It could be literally any keywords, from any project

2020-10-13T14:19:41.009700Z

yeah that makes a lot of sense

kwrooijen 2020-10-13T14:20:02.009900Z

e.g. you could document Onyx keys

kwrooijen 2020-10-13T14:20:18.010400Z

They also have quite a few. Thankfully namespaced

kwrooijen 2020-10-13T14:20:59.010700Z

That being said, maybe we should only support namespaced keywords

kwrooijen 2020-10-13T14:21:15.010900Z

e.g. :name could literally be anything

2020-10-13T14:23:06.011100Z

Obviously by specifying/documenting it as a format we’re punting on rendering. I was hoping eventually that it would be integrated with other clojure docs, e.g. codox though… i.e. my workaround was just going to be putting these docs into namespaces, and writing components in such a way that the primary components people would be interested in would be split one per namespace.

kwrooijen 2020-10-13T14:24:53.011400Z

The namespace being the project name, possibly?

2020-10-13T14:26:42.011600Z

well integrant already requires namespaced keys at the top level… but not within a component. We probably need an equivalent of :req-un, i.e. perhaps the doc key is namespaced but the required key isn’t.

kwrooijen 2020-10-13T14:27:10.011800Z

Having them namespaced in a nested map would prevent conflicts, if that's what you mean?

2020-10-13T14:27:12.012Z

also not all components have maps of config… some are primitive values, others may be vectors, sets etc

2020-10-13T14:28:02.012200Z

sorry @kevin.van.rooijen this is super interesting to me, but I need to do some other work right now… I’ll have a think and may write up some thoughts ideas on your repo

kwrooijen 2020-10-13T14:28:15.012400Z

👍

2020-10-13T22:23:54.014300Z

I've got a base profile that defines a partial map of configuration for a component, and then that base profile gets merged with dev profile with the same component key getting the rest of its configuration from a reference to another component, but it seems like when the merge of the two profiles happen, the configuration for the common key gets replaced rather than merged.

{:duct.core/environment :development
  
 ... 

 :some/component ; has some of the config
 #ig/ref :another/component
}
{:duct.profile/base
 {:duct.core/project-ns my-project
 
  ...
 
  :some/component ; has the rest of the config
  {:opt-1 "value"
   :opt-2 "value"}}

 :duct.profile/dev #duct/include "dev"}
When I bring a system like this up, I get the config of :some/component being equal to just that provided by the dev profile, rather than the dev and base profile merged.

2020-10-13T22:29:30.015300Z

Is it not possible to merge the config maps for a key where some of the config is provided by an Integrant reference and the rest is provided by a simple map?