[spec] specs in registry lack :file metadata despite having :line, :column

Description

As of 1.9.0-alpha13, specs in the registry lack :file metadata despite having :line, :column

This would be useful because:

  • we could list all the specs defined in a project, by filtering the registry.

  • we could read the source of a spec, like clojure.repl/source, for pretty formatting.

(specifically, for use in Codox https://github.com/weavejester/codox/pull/134 )

I had a quick look but couldn't see where the metadata is set.
Cheers

Environment

None

Activity

Show:

Martin Klepsch July 24, 2018 at 5:40 PM

I've been looking into fixing this and for specs that aren't ident? we can use metadata or the map describing regex? specs.

For ident? specs I'm not sure how to handle the additional data — it could be stored in some other location of the registry which might be a viable path.

With any of these approaches it's unclear to me how to integrate this information into the return value of get-spec in a consistent way since it's return value may not be maps (therefore not extensible.)

Storing them in a different location in the registry would work as mentioned before but then we would need another function or protocol method to get information about source file/line/column.

Jozef Wagner December 1, 2016 at 6:31 PM

Note that current :line and :column meta are not pointing to the place where the spec was defined but to the clojure/spec.clj file, e.g. second example (c.c/let) points to fspec-impl

import October 13, 2016 at 5:29 AM

Comment made by: floybix

The following works in my tests. (For testing I used in-ns, @#'registry-ref, #'ns-qualify)).

The approach is to set the registry item metadata after a def. It is not enough to set metadata on the def'd value because it is subsequently altered inside def.

You can use s/describe or s/form to grab the source of a spec now, btw.

Yes, that's nice except for longer specs when line wrapping and indentation would help.

Alex Miller October 8, 2016 at 5:12 PM

You can use s/describe or s/form to grab the source of a spec now, btw.

Details

Assignee

Reporter

Labels

Approval

Triaged

Priority

Affects versions

Created October 8, 2016 at 4:57 PM
Updated May 21, 2024 at 3:04 PM