Skip to content

Commit

Permalink
Merge pull request #430 from chewing/docs/release-0.6.0-crate-doc
Browse files Browse the repository at this point in the history
docs: document crate
  • Loading branch information
kanru authored Jan 18, 2024
2 parents 5d845bb + 7ecada3 commit 4788576
Show file tree
Hide file tree
Showing 20 changed files with 1,215 additions and 141 deletions.
15 changes: 15 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
"minor": 21
},
"configurePresets": [
{
"name": "default",
"displayName": "Default (Release)",
"description": "Default preset for release build",
"inherits": [
"c99-release"
]
},
{
"name": "coverage-base",
"displayName": "Enable Coverage",
Expand Down Expand Up @@ -89,6 +97,7 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"BUILD_INFO": true,
"WITH_RUST": false,
"WITH_SQLITE3": true
}
Expand Down Expand Up @@ -145,5 +154,11 @@
"coverage-base"
]
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
]
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "chewing"
description = "The Chewing (酷音) intelligent Zhuyin input method."
license = "LGPL-2.1-or-later"
documentation = "https://docs.rs/chewing"
version = "0.6.0-alpha.1"
version = "0.6.0-alpha.2"
rust-version = "1.70"
edition = "2021"

Expand Down Expand Up @@ -47,3 +47,7 @@ resolver = "2"
lto = true
debug = true
panic = "abort"

[package.metadata.docs.rs]
features = ["capi", "sqlite"]
# rustdoc-args = ["-Zunstable-options", "--sort-modules-by-appearance"]
6 changes: 1 addition & 5 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,5 @@ if (BUILD_INFO AND MAKEINFO)
add_custom_target(INFO ALL DEPENDS ${INFO_BIN})
add_dependencies(check INFO)

find_program(INSTALL_INFO NAMES ginstall-info install-info)
if (INSTALL_INFO)
install(FILES ${INFO_BIN} DESTINATION ${CMAKE_INSTALL_INFODIR})
install(CODE "execute_process(COMMAND ${INSTALL_INFO} --info-dir=${CMAKE_INSTALL_INFODIR} ${INFO_BIN})")
endif()
install(FILES ${INFO_BIN} TYPE INFO)
endif()
8 changes: 4 additions & 4 deletions doc/libchewing.texi
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,8 @@ This function checks if the candidates selection has finished.
@section Candidates Behavior

@deftypefun void chewing_set_candPerPage (ChewingContext *@var{ctx}, int @var{n})
This function sets the candidates per page to @var{n}. If MIN_SELKEY @leq{}
@var{n} @leq{} @code{MAX_SELKEY} is not true or the number of selection keys is
This function sets the candidates per page to @var{n}. If MIN_SELKEY <=
@var{n} <= @code{MAX_SELKEY} is not true or the number of selection keys is
not enough, the @var{n} will be ignored. The default candidates per page is
@code{MAX_SELKEY}.
@end deftypefun
Expand Down Expand Up @@ -714,7 +714,7 @@ This function closes the candidate windows. It returns @code{0} when success,
@deftypefun const char* chewing_cand_string_by_index_static (ChewingContext *@var{ctx}, int
@var{index})
This function returns the candidate string by its index. The range of
@var{index} shall be @code{0} @leq{} @var{index} <
@var{index} shall be @code{0} <= @var{index} <
@code{chewing_cand_TotalChoice}. This function returns @code{NULL} when no
memory.

Expand All @@ -725,7 +725,7 @@ be freed by the next time be used.
@deftypefun int chewing_cand_choose_by_index (ChewingContext *@var{ctx}, int
@var{index})
This function chooses the candidate by its index. The range of @var{index}
shall be @code{0} @leq{} @var{index} < @code{chewing_cand_TotalChoice}. This
shall be @code{0} <= @var{index} < @code{chewing_cand_TotalChoice}. This
function returns @code{0} when success, @code{-1} otherwise.
@end deftypefun

Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions src/capi/internal/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//! Internal functions visible for tests only
mod key2pho;
mod path;
mod utf8;

pub use key2pho::*;
pub use path::*;
pub use utf8::*;
File renamed without changes.
File renamed without changes.
21 changes: 10 additions & 11 deletions src/capi/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@ use std::{
use tracing::{debug, warn};

use crate::{
capi::{
public::{
ChewingConfigData, IntervalType, CHINESE_MODE, FULLSHAPE_MODE, HALFSHAPE_MODE,
MAX_SELKEY, SYMBOL_MODE,
},
types::{ChewingContext, SelKeys},
capi::public::{
ChewingConfigData, ChewingContext, IntervalType, SelKeys, CHINESE_MODE, FULLSHAPE_MODE,
HALFSHAPE_MODE, MAX_SELKEY, SYMBOL_MODE,
},
conversion::{ChewingEngine, Interval, Symbol},
dictionary::{LayeredDictionary, SystemDictionaryLoader, UserDictionaryLoader},
editor::{
keyboard::{AnyKeyboardLayout, KeyCode, KeyboardLayout, Modifiers, Qwerty},
syllable::{
DaiChien26, Et, Et26, GinYieh, Hsu, Ibm, KeyboardLayoutCompat, Pinyin, Standard,
SyllableEditor,
},
BasicEditor, CharacterForm, Editor, EditorKeyBehavior, EditorOptions, LanguageMode,
LaxUserFreqEstimate, SyllableEditor, UserPhraseAddDirection,
LaxUserFreqEstimate, UserPhraseAddDirection,
},
zhuyin::Syllable,
};
Expand Down Expand Up @@ -135,8 +133,8 @@ pub extern "C" fn chewing_new2(
SystemDictionaryLoader::new().sys_path(search_path).load()
};
let dictionaries = match dictionaries {
Some(d) => d,
None => return null_mut(),
Ok(d) => d,
Err(_) => return null_mut(),
};
let user_dictionary = if userpath.is_null() {
UserDictionaryLoader::new().load()
Expand All @@ -149,8 +147,8 @@ pub extern "C" fn chewing_new2(
.load()
};
let user_dictionary = match user_dictionary {
Some(d) => d,
None => return null_mut(),
Ok(d) => d,
Err(_) => return null_mut(),
};

let estimate = LaxUserFreqEstimate::open(user_dictionary.as_ref());
Expand Down Expand Up @@ -1549,6 +1547,7 @@ pub extern "C" fn chewing_cursor_Current(ctx: *const ChewingContext) -> c_int {
ctx.editor.cursor() as c_int
}

#[deprecated(note = "The chewing_cand_TotalPage function could achieve the same effect.")]
#[tracing::instrument(skip(ctx), ret)]
#[no_mangle]
pub extern "C" fn chewing_cand_CheckDone(ctx: *const ChewingContext) -> c_int {
Expand Down
Loading

0 comments on commit 4788576

Please sign in to comment.