Skip to content

Commit

Permalink
👷 Add readthedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 13, 2024
1 parent 000abad commit 03e9169
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
_readthedocs/

/cppjieba/
/lua/jieba/dict/

Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ repos:
- mdformat-config
- mdformat-web
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.15.0
rev: v0.16.0
hooks:
- id: markdownlint-cli2
additional_dependencies:
- markdown-it-texmath
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.3
rev: v19.1.5
hooks:
- id: clang-format
- repo: https://github.com/lunarmodules/luacheck
Expand Down
12 changes: 12 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://docs.readthedocs.io/en/stable/config-file/v2.html
---
version: 2

build:
os: ubuntu-22.04
tools:
python: "3"
commands:
- pip install hererocks
- hererocks ~/lua -l5.1 -rlatest
- scripts/ldoc.sh
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# jieba.nvim

[![readthedocs](https://shields.io/readthedocs/jieba-nvim)](https://jieba-nvim.readthedocs.io)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Freed-Wu/jieba.nvim/main.svg)](https://results.pre-commit.ci/latest/github/Freed-Wu/jieba.nvim/main)
[![github/workflow](https://github.com/Freed-Wu/jieba.nvim/actions/workflows/main.yml/badge.svg)](https://github.com/Freed-Wu/jieba.nvim/actions)

Expand Down
7 changes: 7 additions & 0 deletions config.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---ldoc config
-- luacheck: ignore 111
---@diagnostic disable: lowercase-global
project = "jieba.nvim"
readme = "README.md"
format = "cmark"
dir = "_readthedocs/html"
18 changes: 12 additions & 6 deletions lua/jieba/config.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-- luacheck: ignore 112 113
--- default config. See `lua vim.print(require"jieba.config")`.
---@diagnostic disable: undefined-global
-- luacheck: ignore 112 113

---get dirname
---@param dir string
---@return string
local function dirname(dir)
Expand All @@ -11,6 +13,7 @@ local function dirname(dir)
return result
end

---join two paths
---@param dir string
---@param file string
---@return string
Expand All @@ -21,6 +24,7 @@ local function joinpath(dir, file)
return dir .. "/" .. file
end

---judge if OS is win32
---@return boolean
local function has_win32()
if vim then
Expand All @@ -35,12 +39,14 @@ local dict_dir = joinpath(
)

return {
--- if hmm is enabled
hmm = true,
--- config for paths
paths = {
dict_path = joinpath(dict_dir, "jieba.dict.utf8"),
model_path = joinpath(dict_dir, "hmm_model.utf8"),
user_dict_path = has_win32() and "nul" or "/dev/null",
idf_path = joinpath(dict_dir, "idf.utf8"),
stop_word_path = joinpath(dict_dir, "stop_words.utf8"),
dict_path = joinpath(dict_dir, "jieba.dict.utf8"), -- for dict
model_path = joinpath(dict_dir, "hmm_model.utf8"), -- for model
user_dict_path = has_win32() and "nul" or "/dev/null", -- for user dict
idf_path = joinpath(dict_dir, "idf.utf8"), -- for idf
stop_word_path = joinpath(dict_dir, "stop_words.utf8"), -- for stop words
}
}
3 changes: 2 additions & 1 deletion lua/jieba/nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- luacheck: ignore 112 113
--- copied from <https://github.com/neo451/jieba.nvim/>
---@diagnostic disable: undefined-global
-- luacheck: ignore 112 113
-- This code snippet is taken from [kkew3/jieba.vim] and is licensed under the MIT License.
-- Original License Text:
-- MIT License
Expand Down
1 change: 1 addition & 0 deletions lua/jieba/utils.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
--- copied from <https://github.com/neo451/jieba.nvim/>
local M = {}
-- local utf8 = require("lua-utf8")
-- local utf8 = require("jieba.utf8")
Expand Down
7 changes: 7 additions & 0 deletions scripts/ldoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "$(dirname "$(readlink -f "$0")")")"

. ~/lua/bin/activate &&
luarocks install ldoc &&
ldoc .
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mkShell {
(luajit.withPackages (
p: with p; [
busted
ldoc
]
))
];
Expand Down

0 comments on commit 03e9169

Please sign in to comment.