Improve how static fields are converted to keywords
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
{"Actor" {"actor!" :methods}
|
{"Actor" {"actor!" :methods}
|
||||||
"ActorGestureListener" {"actor-gesture-listener!" :methods}
|
"ActorGestureListener" {"actor-gesture-listener!" :methods}
|
||||||
"Align" {"align" :static-fields}
|
"Align" {"align" :static-fields-camel}
|
||||||
"com.badlogic.gdx.graphics.g2d.Animation" {"animation" :methods
|
"com.badlogic.gdx.graphics.g2d.Animation" {"animation" :methods
|
||||||
"animation!" :methods}
|
"animation!" :methods}
|
||||||
"Animation.PlayMode" {"play-mode" :static-fields}
|
"Animation.PlayMode" {"play-mode" :static-fields-upper}
|
||||||
"AnimationController" {"animation-controller" :methods
|
"AnimationController" {"animation-controller" :methods
|
||||||
"animation-controller!" :methods}
|
"animation-controller!" :methods}
|
||||||
"Application" {"app!" :methods}
|
"Application" {"app!" :methods}
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
"BitmapFont" {"bitmap-font" :methods
|
"BitmapFont" {"bitmap-font" :methods
|
||||||
"bitmap-font!" :methods}
|
"bitmap-font!" :methods}
|
||||||
"BlendingAttribute" {"attribute :blending" :constructors
|
"BlendingAttribute" {"attribute :blending" :constructors
|
||||||
"attribute-type :blending" :static-fields
|
"attribute-type :blending" :static-fields-pascal
|
||||||
"attribute! :blending" :static-methods}
|
"attribute! :blending" :static-methods}
|
||||||
"Body" {"body!" :methods}
|
"Body" {"body!" :methods}
|
||||||
"BodyDef" {"body-def" :fields}
|
"BodyDef" {"body-def" :fields}
|
||||||
@@ -37,10 +37,10 @@
|
|||||||
"CircleMapObject" {"map-object :circle" :methods}
|
"CircleMapObject" {"map-object :circle" :methods}
|
||||||
"ChangeListener" {"change-listener!" :methods}
|
"ChangeListener" {"change-listener!" :methods}
|
||||||
"ClickListener" {"click-listener!" :methods}
|
"ClickListener" {"click-listener!" :methods}
|
||||||
"Color" {"color" :static-fields
|
"Color" {"color" :static-fields-upper
|
||||||
"color!" :methods}
|
"color!" :methods}
|
||||||
"ColorAttribute" {"attribute :color" :constructors
|
"ColorAttribute" {"attribute :color" :constructors
|
||||||
"attribute-type :color" :static-fields
|
"attribute-type :color" :static-fields-pascal
|
||||||
"attribute! :color" :static-methods}
|
"attribute! :color" :static-methods}
|
||||||
"ConvexHull" {"convex-hull" :methods
|
"ConvexHull" {"convex-hull" :methods
|
||||||
"convex-hull!" :methods}
|
"convex-hull!" :methods}
|
||||||
@@ -52,12 +52,12 @@
|
|||||||
"CircleShape" {"circle-shape" :methods
|
"CircleShape" {"circle-shape" :methods
|
||||||
"circle-shape!" :methods}
|
"circle-shape!" :methods}
|
||||||
"CubemapAttribute" {"attribute :cubemap" :constructors
|
"CubemapAttribute" {"attribute :cubemap" :constructors
|
||||||
"attribute-type :cubemap" :static-fields
|
"attribute-type :cubemap" :static-fields-pascal
|
||||||
"attribute! :cubemap" :static-methods}
|
"attribute! :cubemap" :static-methods}
|
||||||
"DelaunayTriangulator" {"delaunay-triangulator" :methods
|
"DelaunayTriangulator" {"delaunay-triangulator" :methods
|
||||||
"delaunay-triangulator!" :methods}
|
"delaunay-triangulator!" :methods}
|
||||||
"DepthTestAttribute" {"attribute :depth-test" :constructors
|
"DepthTestAttribute" {"attribute :depth-test" :constructors
|
||||||
"attribute-type :depth-test" :static-fields
|
"attribute-type :depth-test" :static-fields-pascal
|
||||||
"attribute! :depth-test" :static-methods}
|
"attribute! :depth-test" :static-methods}
|
||||||
"Dialog" {"dialog" :methods
|
"Dialog" {"dialog" :methods
|
||||||
"dialog!" :methods}
|
"dialog!" :methods}
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
"Fixture" {"fixture!" :methods}
|
"Fixture" {"fixture!" :methods}
|
||||||
"FixtureDef" {"fixture-def" :fields}
|
"FixtureDef" {"fixture-def" :fields}
|
||||||
"FloatAttribute" {"attribute :float" :constructors
|
"FloatAttribute" {"attribute :float" :constructors
|
||||||
"attribute-type :float" :static-fields
|
"attribute-type :float" :static-fields-pascal
|
||||||
"attribute! :float" :static-methods}
|
"attribute! :float" :static-methods}
|
||||||
"FloatCounter" {"float-counter" :methods
|
"FloatCounter" {"float-counter" :methods
|
||||||
"float-counter!" :methods}
|
"float-counter!" :methods}
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
"GridPoint3" {"grid-point-3" :methods
|
"GridPoint3" {"grid-point-3" :methods
|
||||||
"grid-point-3!" :methods}
|
"grid-point-3!" :methods}
|
||||||
"GL20" {"gl!" :methods
|
"GL20" {"gl!" :methods
|
||||||
"gl" :static-fields}
|
"gl" :static-fields-upper}
|
||||||
"HexagonalTiledMapRenderer" {"hexagonal-tiled-map" :methods
|
"HexagonalTiledMapRenderer" {"hexagonal-tiled-map" :methods
|
||||||
"hexagonal-tiled-map!" :methods}
|
"hexagonal-tiled-map!" :methods}
|
||||||
"HorizontalGroup" {"horizontal" :methods
|
"HorizontalGroup" {"horizontal" :methods
|
||||||
@@ -107,15 +107,15 @@
|
|||||||
"image-text-button!" :methods}
|
"image-text-button!" :methods}
|
||||||
"ImageTextButton.ImageTextButtonStyle" {"style :image-text-button" :constructors}
|
"ImageTextButton.ImageTextButtonStyle" {"style :image-text-button" :constructors}
|
||||||
"Input" {"input!" :methods}
|
"Input" {"input!" :methods}
|
||||||
"Input.Keys" {"key-code" :static-fields
|
"Input.Keys" {"key-code" :static-fields-upper
|
||||||
"key-pressed?" :static-fields}
|
"key-pressed?" :static-fields-upper}
|
||||||
"Input.Buttons" {"button-code" :static-fields
|
"Input.Buttons" {"button-code" :static-fields-upper
|
||||||
"button-pressed?" :static-fields}
|
"button-pressed?" :static-fields-upper}
|
||||||
"InputProcessor" {"input-processor!" :methods}
|
"InputProcessor" {"input-processor!" :methods}
|
||||||
"Interpolation" {"interpolation" :static-classes}
|
"Interpolation" {"interpolation" :static-classes}
|
||||||
"Intersector" {"intersector!" :static-methods}
|
"Intersector" {"intersector!" :static-methods}
|
||||||
"IntAttribute" {"attribute :int" :constructors
|
"IntAttribute" {"attribute :int" :constructors
|
||||||
"attribute-type :int" :static-fields
|
"attribute-type :int" :static-fields-pascal
|
||||||
"attribute! :int" :static-methods}
|
"attribute! :int" :static-methods}
|
||||||
"IsometricStaggeredTiledMapRenderer" {"isometric-staggered-tiled-map" :methods
|
"IsometricStaggeredTiledMapRenderer" {"isometric-staggered-tiled-map" :methods
|
||||||
"isometric-staggered-tiled-map!" :methods}
|
"isometric-staggered-tiled-map!" :methods}
|
||||||
@@ -162,10 +162,10 @@
|
|||||||
"perspective!" :methods}
|
"perspective!" :methods}
|
||||||
"Pixmap" {"pixmap" :methods
|
"Pixmap" {"pixmap" :methods
|
||||||
"pixmap!" :methods}
|
"pixmap!" :methods}
|
||||||
"Pixmap.Format" {"pixmap-format" :static-fields}
|
"Pixmap.Format" {"pixmap-format" :static-fields-pascal}
|
||||||
"Plane" {"plane" :methods
|
"Plane" {"plane" :methods
|
||||||
"plane!" :methods}
|
"plane!" :methods}
|
||||||
"Plane.PlaneSide" {"plane-side" :static-fields}
|
"Plane.PlaneSide" {"plane-side" :static-fields-pascal}
|
||||||
"Polygon" {"polygon" :methods
|
"Polygon" {"polygon" :methods
|
||||||
"polygon!" :methods}
|
"polygon!" :methods}
|
||||||
"PolygonMapObject" {"map-object :polygon" :methods}
|
"PolygonMapObject" {"map-object :polygon" :methods}
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
"RectangleMapObject" {"map-object :rectangle" :methods}
|
"RectangleMapObject" {"map-object :rectangle" :methods}
|
||||||
"RevoluteJointDef" {"joint-def :revolute" :fields}
|
"RevoluteJointDef" {"joint-def :revolute" :fields}
|
||||||
"RopeJointDef" {"joint-def :rope" :fields}
|
"RopeJointDef" {"joint-def :rope" :fields}
|
||||||
"Scaling" {"scaling" :static-fields}
|
"Scaling" {"scaling" :static-fields-camel}
|
||||||
"ScrollPane" {"scroll-pane" :methods
|
"ScrollPane" {"scroll-pane" :methods
|
||||||
"scroll-pane!" :methods}
|
"scroll-pane!" :methods}
|
||||||
"ScrollPane.ScrollPaneStyle" {"style :scroll-pane" :constructors}
|
"ScrollPane.ScrollPaneStyle" {"style :scroll-pane" :constructors}
|
||||||
@@ -198,7 +198,7 @@
|
|||||||
"SelectBox.SelectBoxStyle" {"style :select-box" :constructors}
|
"SelectBox.SelectBoxStyle" {"style :select-box" :constructors}
|
||||||
"ShapeRenderer" {"shape" :methods
|
"ShapeRenderer" {"shape" :methods
|
||||||
"shape!" :methods}
|
"shape!" :methods}
|
||||||
"ShapeRenderer.ShapeType" {"shape-type" :static-fields}
|
"ShapeRenderer.ShapeType" {"shape-type" :static-fields-pascal}
|
||||||
"Skin" {"skin" :methods
|
"Skin" {"skin" :methods
|
||||||
"skin!" :methods}
|
"skin!" :methods}
|
||||||
"Slider" {"slider" :methods
|
"Slider" {"slider" :methods
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
"TextureAtlas" {"texture-atlas" :methods
|
"TextureAtlas" {"texture-atlas" :methods
|
||||||
"texture-atlas!" :methods}
|
"texture-atlas!" :methods}
|
||||||
"TextureAttribute" {"attribute :texture" :constructors
|
"TextureAttribute" {"attribute :texture" :constructors
|
||||||
"attribute-type :texture" :static-fields
|
"attribute-type :texture" :static-fields-pascal
|
||||||
"attribute! :texture" :static-methods}
|
"attribute! :texture" :static-methods}
|
||||||
"TextButton" {"text-button" :methods
|
"TextButton" {"text-button" :methods
|
||||||
"text-button!" :methods}
|
"text-button!" :methods}
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
"vector-2!" :methods}
|
"vector-2!" :methods}
|
||||||
"Vector3" {"vector-3" :methods
|
"Vector3" {"vector-3" :methods
|
||||||
"vector-3!" :methods}
|
"vector-3!" :methods}
|
||||||
"VertexAttributes.Usage" {"usage" :static-fields}
|
"VertexAttributes.Usage" {"usage" :static-fields-pascal}
|
||||||
"VerticalGroup" {"vertical" :methods
|
"VerticalGroup" {"vertical" :methods
|
||||||
"vertical!" :methods}
|
"vertical!" :methods}
|
||||||
"WeldJointDef" {"joint-def :weld" :fields}
|
"WeldJointDef" {"joint-def :weld" :fields}
|
||||||
|
|||||||
@@ -13,49 +13,55 @@
|
|||||||
|
|
||||||
(def classes (-> "classes.edn" io/resource slurp edn/read-string))
|
(def classes (-> "classes.edn" io/resource slurp edn/read-string))
|
||||||
|
|
||||||
(defn split-string
|
|
||||||
[s]
|
|
||||||
(if (= s (string/upper-case s))
|
|
||||||
(string/split s #"_")
|
|
||||||
(string/split s #"(?=[A-Z])")))
|
|
||||||
|
|
||||||
(defn string->keyword
|
(defn string->keyword
|
||||||
[s]
|
[s case-type]
|
||||||
(->> (split-string s)
|
(->> (case case-type
|
||||||
|
:upper #"_"
|
||||||
|
:pascal #"(?<=.)(?=[A-Z])"
|
||||||
|
:camel #"(?=[A-Z])"
|
||||||
|
(throw (Exception. "Unrecognized case type.")))
|
||||||
|
(string/split s)
|
||||||
(map string/lower-case)
|
(map string/lower-case)
|
||||||
(string/join "-")
|
(string/join "-")
|
||||||
keyword))
|
keyword))
|
||||||
|
|
||||||
(defn parse-param
|
(defn parse-param
|
||||||
[^Parameter p]
|
[^Parameter p]
|
||||||
[(.typeName p) (-> (.name p) string->keyword name)])
|
[(.typeName p) (-> (.name p) (string->keyword :camel) name)])
|
||||||
|
|
||||||
|
(defn after-last-period
|
||||||
|
[^String s]
|
||||||
|
(subs s (+ 1 (.lastIndexOf s "."))))
|
||||||
|
|
||||||
(defn parse-doc-name
|
(defn parse-doc-name
|
||||||
[^Doc d]
|
[^String doc-name doc-type]
|
||||||
(cond
|
(case doc-type
|
||||||
(isa? (type d) ConstructorDoc)
|
:constructors
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(isa? (type d) ClassDoc)
|
:classes
|
||||||
(->> (+ 1 (.lastIndexOf (.name d) "."))
|
(string->keyword (after-last-period doc-name) :pascal)
|
||||||
(subs (.name d))
|
|
||||||
string->keyword)
|
:static-classes
|
||||||
|
(string->keyword (after-last-period doc-name) :pascal)
|
||||||
(isa? (type d) FieldDoc)
|
|
||||||
(let [k (string->keyword (.name d))
|
:static-fields-upper
|
||||||
s (name k)]
|
(string->keyword doc-name :upper)
|
||||||
(if (= \- (first s))
|
|
||||||
(keyword (subs s 1))
|
:static-fields-pascal
|
||||||
k))
|
(string->keyword doc-name :pascal)
|
||||||
|
|
||||||
:else
|
:static-fields-camel
|
||||||
(string->keyword (.name d))))
|
(string->keyword doc-name :camel)
|
||||||
|
|
||||||
|
; else
|
||||||
|
(string->keyword doc-name :camel)))
|
||||||
|
|
||||||
(defn parse-doc
|
(defn parse-doc
|
||||||
[^Doc d clj-name]
|
[^Doc d clj-name doc-type]
|
||||||
(merge {}
|
(merge {}
|
||||||
{:name (->> [(second (string/split clj-name #" "))
|
{:name (->> [(second (string/split clj-name #" "))
|
||||||
(parse-doc-name d)]
|
(parse-doc-name (.name d) doc-type)]
|
||||||
(remove nil?)
|
(remove nil?)
|
||||||
(string/join " "))}
|
(string/join " "))}
|
||||||
(when (> (count (.commentText d)) 0)
|
(when (> (count (.commentText d)) 0)
|
||||||
@@ -70,18 +76,20 @@
|
|||||||
{:args [[(-> d .type .typeName) "value"]]})))
|
{:args [[(-> d .type .typeName) "value"]]})))
|
||||||
|
|
||||||
(defn parse-class-entry
|
(defn parse-class-entry
|
||||||
[^ClassDoc c [clj-name type]]
|
[^ClassDoc c [clj-name doc-type]]
|
||||||
(some->> (case type
|
(some->> (case doc-type
|
||||||
:methods (filter #(-> % .isStatic not) (.methods c))
|
:methods (filter #(-> % .isStatic not) (.methods c))
|
||||||
:static-methods (filter #(.isStatic %) (.methods c))
|
:static-methods (filter #(.isStatic %) (.methods c))
|
||||||
:fields (filter #(-> % .isStatic not) (.fields c))
|
:fields (filter #(-> % .isStatic not) (.fields c))
|
||||||
:static-fields (filter #(.isStatic %) (.fields c))
|
:static-fields-upper (filter #(.isStatic %) (.fields c))
|
||||||
|
:static-fields-pascal (filter #(.isStatic %) (.fields c))
|
||||||
|
:static-fields-camel (filter #(.isStatic %) (.fields c))
|
||||||
:classes (filter #(-> % .isStatic not) (.innerClasses c))
|
:classes (filter #(-> % .isStatic not) (.innerClasses c))
|
||||||
:static-classes (filter #(.isStatic %) (.innerClasses c))
|
:static-classes (filter #(.isStatic %) (.innerClasses c))
|
||||||
:constructors (filter #(-> % .isStatic not) (.constructors c))
|
:constructors (filter #(-> % .isStatic not) (.constructors c))
|
||||||
nil)
|
nil)
|
||||||
(filter #(.isPublic %))
|
(filter #(.isPublic %))
|
||||||
(map #(parse-doc % clj-name))
|
(map #(parse-doc % clj-name doc-type))
|
||||||
(concat (when-let [sc (.superclass c)]
|
(concat (when-let [sc (.superclass c)]
|
||||||
(when (not= (.typeName sc) "Object")
|
(when (not= (.typeName sc) "Object")
|
||||||
(parse-class-entry sc [clj-name type]))))
|
(parse-class-entry sc [clj-name type]))))
|
||||||
|
|||||||
Reference in New Issue
Block a user