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

New pursuit #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,673 changes: 1,349 additions & 324 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"scripts": {
"test": "spago docs --no-search && ./dist/purescript-docs-search.cjs build-index && spago test && npm run check-version",
"bundle-app": "spago bundle-app --no-build --no-install -m Docs.Search.App --to dist/docs-search-app.js",
"esbuild-app": "esbuild dist/docs-search-app.js --target=es2016 --bundle --minify --outfile=dist/docs-search-app.min.js && mv dist/docs-search-app.min.js dist/docs-search-app.js",
"esbuild-app": "esbuild dist/docs-search-app.js --target=es2016 --bundle --outfile=dist/docs-search-app.min.js && mv dist/docs-search-app.min.js dist/docs-search-app.js",
"build-app": "npm run bundle-app && npm run esbuild-app",
"bundle-main": "spago bundle-app --no-build --no-install --platform node -m Docs.Search.Main --to dist/main.js",
"esbuild-main": "esbuild dist/main.js --platform=node --bundle --minify --outfile=dist/main.min.js && mv dist/main.min.js dist/main.js",
"esbuild-main": "esbuild dist/main.js --platform=node --bundle --outfile=dist/main.min.js && mv dist/main.min.js dist/main.js",
"add-shebang": "echo \"#!/usr/bin/env node\" > dist/purescript-docs-search.cjs && cat dist/main.js >> dist/purescript-docs-search.cjs",
"chmod-main": "chmod +x dist/purescript-docs-search.cjs",
"build-main": "npm run bundle-main && npm run esbuild-main && npm run add-shebang && rm dist/main.js && npm run chmod-main",
Expand All @@ -48,8 +48,9 @@
"devDependencies": {
"esbuild": "^0.11.10",
"glob": "^7.1.6",
"http-server": "^14.1.1",
"markdown-it": "^12.0.4",
"puppeteer": "^8.0.0",
"puppeteer": "^19.2.2",
"spago": "^0.20.9"
}
}
6 changes: 4 additions & 2 deletions packages.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ let mkPackage =
sha256:0b197efa1d397ace6eb46b243ff2d73a3da5638d8d0ac8473e8e4a8fc528cf57

let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.15.4-20220829/packages.dhall
sha256:9ec64ed24ec308770ccdd3d0edb74a814fcfbe34c7df5c28266935f0b5e585d7
https://github.com/purescript/package-sets/releases/download/psc-0.15.7-20230118/packages.dhall
sha256:973809c5d08a285ac10c6e66be04ca2c85a2d26493644e9196a6a411359f84b9

let overrides = {=}

Expand Down Expand Up @@ -177,6 +177,8 @@ let additions =
]
"https://github.com/jvliwanag/purescript-untagged-union.git"
"ed8262a966e15e751322c327e2759a9b9c0ef3f3"
, next-website-commons =
../purescript-next-website-commons/spago.dhall as Location
}

in upstream // overrides // additions
6 changes: 6 additions & 0 deletions spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, dependencies =
[ "aff"
, "aff-promise"
, "argonaut"
, "argonaut-codecs"
, "argonaut-core"
, "argonaut-generic"
Expand All @@ -19,13 +20,17 @@
, "halogen"
, "halogen-css"
, "halogen-subscriptions"
, "httpurple"
, "httpurple-argonaut"
, "httpurple-yoga-json"
, "identity"
, "js-uri"
, "lists"
, "markdown-it"
, "markdown-it-halogen"
, "maybe"
, "newtype"
, "next-website-commons"
, "node-buffer"
, "node-fs"
, "node-fs-aff"
Expand All @@ -50,6 +55,7 @@
, "web-html"
, "web-storage"
, "web-uievents"
, "yoga-json"
]
, packages = ./packages.dhall
}
23 changes: 16 additions & 7 deletions src/Docs/Search/Engine.purs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
module Docs.Search.Engine where

import Docs.Search.ModuleIndex (ModuleIndex, ModuleResult)
import Docs.Search.PackageIndex (PackageIndex, PackageResult)
import Docs.Search.Score (Scores)
import Docs.Search.SearchResult (SearchResult, typeOfResult)
import Docs.Search.TypeQuery (TypeQuery(..), parseTypeQuery, penalty)
import Docs.Search.Types (PackageInfo(..), ModuleName(..), PackageName(..), PackageScore)

import Prelude

import Data.Argonaut (class DecodeJson, class EncodeJson)
import Data.Argonaut.Decode.Generic (genericDecodeJson)
import Data.Argonaut.Encode.Generic (genericEncodeJson)
import Data.Array as Array
import Data.Either (hush)
import Data.Function (on)
import Data.Generic.Rep (class Generic)
import Data.List (List)
import Data.Maybe (Maybe(..))
import Data.Newtype (unwrap)
import Data.Search.Trie (Trie)
import Data.String.Common (toLower) as String
import Docs.Search.ModuleIndex (ModuleIndex, ModuleResult)
import Docs.Search.PackageIndex (PackageIndex, PackageResult)
import Docs.Search.Score (Scores)
import Docs.Search.SearchResult (SearchResult, typeOfResult)
import Docs.Search.TypeQuery (TypeQuery(..), parseTypeQuery, penalty)
import Docs.Search.Types (PackageInfo(..), ModuleName(..), PackageName(..), PackageScore)


type Index = Trie Char (List SearchResult)
Expand Down Expand Up @@ -64,7 +67,13 @@ data Result
| TypeResult SearchResult
| PackResult PackageResult
| MdlResult ModuleResult
derive instance Generic Result _

instance EncodeJson Result where
encodeJson = genericEncodeJson

instance DecodeJson Result where
decodeJson = genericDecodeJson

getResultScore :: Result -> PackageScore
getResultScore (DeclResult r) = (unwrap r).score
Expand Down
Loading