Skip to content

Commit

Permalink
fix code indentation; expand documentation on rest/stdio api
Browse files Browse the repository at this point in the history
  • Loading branch information
arvyy committed May 23, 2022
1 parent ddd5b33 commit 71bbb04
Show file tree
Hide file tree
Showing 9 changed files with 992 additions and 853 deletions.
399 changes: 262 additions & 137 deletions README.adoc

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
</appender>

<root level="INFO">
<appender-ref ref="STDOUT" />"
<!--
<appender-ref ref="STDOUT" />
-->
<appender-ref ref="FILE" />
</root>

</configuration>
</configuration>
18 changes: 9 additions & 9 deletions src/main/scheme/main.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
(scmindex repl-ui))

(define config-file
(cond
((= 0 (vector-length command-line-arguments)) "./config/configuration.scm")
(else (vector-ref command-line-arguments 0))))
(cond
((= 0 (vector-length command-line-arguments)) "./config/configuration.scm")
(else (vector-ref command-line-arguments 0))))

(define config (with-input-from-file config-file read))

(define solr-core (deploy-setting/solr-core config))
(define solr-client
(cond
((deploy-setting/solr-embed config) (create-embedded-solr-client (deploy-setting/solr-home config) solr-core))
(else (create-http-solr-client (deploy-setting/solr-url config)))))
(cond
((deploy-setting/solr-embed config) (create-embedded-solr-client (deploy-setting/solr-home config) solr-core))
(else (create-http-solr-client (deploy-setting/solr-url config)))))

(let ((funcs (read-specs (deploy-setting/spec-index config))))
(index-types solr-client solr-core funcs))
(index-types solr-client solr-core funcs))

(when (deploy-setting/enable-web config)
(init-web-ui config solr-client solr-core))
(init-web-ui config solr-client solr-core))

(when (deploy-setting/enable-repl config)
(init-repl-ui config solr-client solr-core))
(init-repl-ui config solr-client solr-core))
220 changes: 110 additions & 110 deletions src/main/scheme/scmindex/domain.scm
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
(define-library
(scmindex domain)
(import (scheme base)
(scheme read)
(scheme write))
(export

make-search-result
search-result?
search-result-items
search-result-total
search-result-libs
search-result-params
search-result-tags
search-result-returns

make-search-result-facet
search-result-facet?
search-result-facet-value
search-result-facet-count

make-func
func?
func-lib
func-name
func-param-names
func-signature
func-param-signatures
func-syntax-param-signatures
func-tags
func-param-types
func-return-types
func-supertypes

func->json
json->func
search-result->json
)
(begin
(scmindex domain)
(import (scheme base)
(scheme read)
(scheme write))
(export

make-search-result
search-result?
search-result-items
search-result-total
search-result-libs
search-result-params
search-result-tags
search-result-returns

make-search-result-facet
search-result-facet?
search-result-facet-value
search-result-facet-count

make-func
func?
func-lib
func-name
func-param-names
func-signature
func-param-signatures
func-syntax-param-signatures
func-tags
func-param-types
func-return-types
func-supertypes

func->json
json->func
search-result->json)

(begin

(define-record-type <scmindex-function>
(make-func
lib
name
param-names
signature
param-signatures
syntax-param-signatures
tags
param-types
return-types
supertypes)

func?

(lib func-lib)
(name func-name)
(param-names func-param-names)
(signature func-signature)
(param-signatures func-param-signatures)
(syntax-param-signatures func-syntax-param-signatures)
(tags func-tags)
(param-types func-param-types)
(return-types func-return-types)
(supertypes func-supertypes))
(make-func
lib
name
param-names
signature
param-signatures
syntax-param-signatures
tags
param-types
return-types
supertypes)

func?

(lib func-lib)
(name func-name)
(param-names func-param-names)
(signature func-signature)
(param-signatures func-param-signatures)
(syntax-param-signatures func-syntax-param-signatures)
(tags func-tags)
(param-types func-param-types)
(return-types func-return-types)
(supertypes func-supertypes))

;;TODO move to util?
(define (->string obj)
Expand All @@ -71,8 +71,8 @@
(get-output-string port))

(define (read* str)
(define port (open-input-string str))
(read port))
(define port (open-input-string str))
(read port))

(define (func->json func)
`((lib . ,(->string (func-lib func)))
Expand All @@ -81,60 +81,60 @@
(signature . ,(->string (func-signature func)))
(param_signatures . ,(->string (func-param-signatures func)))
(syntax_param_signatures . ,(->string (func-syntax-param-signatures func)))
(tags . ,(list->vector (map ->string (func-tags func))))
(param_types . ,(list->vector (map ->string (func-param-types func))))
(return_types . ,(list->vector (map ->string (func-return-types func))))
(super_types . ,(list->vector (map ->string (func-supertypes func))))))
(tags . ,(list->vector (map symbol->string (func-tags func))))
(param_types . ,(list->vector (map symbol->string (func-param-types func))))
(return_types . ,(list->vector (map symbol->string (func-return-types func))))
(super_types . ,(list->vector (map symbol->string (func-supertypes func))))))

(define (json->func json)
(define (get field type default)
(cond
((assoc field json) =>
(lambda (value)
(case type
((sexpr) (read* (cdr value)))
((symbol) (string->symbol (cdr value)))
((symbol-lst) (map string->symbol (vector->list (cdr value))))
(else (cdr value)))))
(else default)))
(make-func
(get 'lib 'sexpr #f)
(get 'name 'symbol #f)
(get 'param_names 'symbol-lst '())
(get 'signature 'sexpr #f)
(get 'param_signatures 'sexpr '())
(get 'syntax_param_signatures 'sexpr '())
(get 'tags 'symbol-lst '())
(get 'param_types 'symbol-lst '())
(get 'return_types 'symbol-lst '())
(get 'supertypes 'symbol-lst '())))
(define (get field type default)
(cond
((assoc field json) =>
(lambda (value)
(case type
((sexpr) (read* (cdr value)))
((symbol) (string->symbol (cdr value)))
((symbol-lst) (map string->symbol (vector->list (cdr value))))
(else (cdr value)))))
(else default)))
(make-func
(get 'lib 'sexpr #f)
(get 'name 'symbol #f)
(get 'param_names 'symbol-lst '())
(get 'signature 'sexpr #f)
(get 'param_signatures 'sexpr '())
(get 'syntax_param_signatures 'sexpr '())
(get 'tags 'symbol-lst '())
(get 'param_types 'symbol-lst '())
(get 'return_types 'symbol-lst '())
(get 'supertypes 'symbol-lst '())))

(define-record-type <search-result>
(make-search-result items total libs params tags returns)
search-result?
(items search-result-items)
(total search-result-total)
(libs search-result-libs)
(params search-result-params)
(tags search-result-tags)
(returns search-result-returns))
(make-search-result items total libs params tags returns)
search-result?
(items search-result-items)
(total search-result-total)
(libs search-result-libs)
(params search-result-params)
(tags search-result-tags)
(returns search-result-returns))

(define-record-type <search-result-facet>
(make-search-result-facet value count)
search-result-facet?
(value search-result-facet-value)
(count search-result-facet-count))
(make-search-result-facet value count)
search-result-facet?
(value search-result-facet-value)
(count search-result-facet-count))

(define (search-result->json sr)
`((items . ,(list->vector (map func->json (search-result-items sr))))
(total . ,(search-result-total sr))
(libs . ,(list->vector (map search-result-facet->json (search-result-libs sr))))
(params . ,(list->vector (map search-result-facet->json (search-result-params sr))))
(returns . ,(list->vector (map search-result-facet->json (search-result-returns sr))))
(tags . ,(list->vector (map search-result-facet->json (search-result-tags sr))))))
`((items . ,(list->vector (map func->json (search-result-items sr))))
(total . ,(search-result-total sr))
(libs . ,(list->vector (map search-result-facet->json (search-result-libs sr))))
(params . ,(list->vector (map search-result-facet->json (search-result-params sr))))
(returns . ,(list->vector (map search-result-facet->json (search-result-returns sr))))
(tags . ,(list->vector (map search-result-facet->json (search-result-tags sr))))))

(define (search-result-facet->json f)
`((value . ,(->string (search-result-facet-value f)))
(count . ,(search-result-facet-count f))))
`((value . ,(search-result-facet-value f))
(count . ,(search-result-facet-count f))))

))
))
Loading

0 comments on commit 71bbb04

Please sign in to comment.