Docfx Russian language search - docfx

How to make docfx to search in Russian language?
It searches English words just fine, but not Russian words. I tried to debug it and can see that it uses lunr library for search. How can I replace standard lunr library with Russian lunr in docfx?

Turns out to be quite easy:
In order to support other languages apart from those which supports lunr use this repo:
https://github.com/MihaiValentin/lunr-languages
Open search-worker.js file from docfx and modify it a bit as readme at github suggest:
Add imports
importScripts('lunr.stemmer.support.js');
importScripts('lunr.ru.js');
Copy these files from github to the folder with lunr.js
Modify the following method:
var lunrIndex = lunr(function() {
this.pipeline.remove(lunr.stopWordFilter);
Add this line...>this.use(lunr.ru);
this.ref('href');
Enjoy.

Related

How can I make the search engine work for multibyte characters (Japanese in particular) in bookdown gitbook?

I have built a gitbook with the bookdown package. The search engine does work for English-written parts of the text and codes (i.e. alphabet and numbers, basically), but I have found it doesn't work at all if I type in some Japanese words.
Is there any ways to make that work?
Thanks.
This problem will be gone if you switch the search engine to fuse (details here):
output:
bookdown::gitbook:
config:
search:
engine: fuse
Currently you need to install the dev version of bookdown:
remotes::install_github('rstudio/bookdown')

Where to put the style guide in an R package

I am currently working on a GitHub-based R package and I would like to add markdown text containing coding style guidelines. The problem is that I can't find the best place to put that information. According to Writing R Extensions, I can't just add a STYLE.md file without having the package fail basic build checks. They say:
The sources of an R package consists of a subdirectory containing a
files DESCRIPTION and NAMESPACE, and the subdirectories R, data, demo,
exec, inst, man, po, src, tests, tools and vignettes (some of which
can be missing, but which should not be empty). The package
subdirectory may also contain files INDEX, configure, cleanup,
LICENSE, LICENCE and NEWS. Other files such as INSTALL (for
non-standard installation instructions), README/README.md, or
ChangeLog will be ignored by R, but may be useful to end users.
So my current solution is to integrate the style guide into README.md file, but I don't like to have it there, because the guide is a secondary thing written for the package contributors and not the users; it should not be visible for everybody visiting the package's homepage (which is what happens for anything written in README.md and pushed to GitHub).
Another thing I thought about doing was to create a vignette for that; the developers of the rockchalk package did just that. However, my guide is much shorter, I don't think it fits well with the spotlight and printing-friendly format of vignettes.
Where else could/should I put the style guide?

Multimarkdown in GitHub's Atom editor - made a start, want to make more progress

To extend the basic Markdown support in Atom, I've converted the TextMate Multimarkdown bundle (unescaping one hash sign - see the process on this Atom discussion). The (converted) TextMate bundle files are now in my Atom config folder.
Markdown syntax now highlights okay (and differently from the built-in GitHub Markdown) when I choose 'Multimarkdown' from the syntax list. The table sytnax appears to pick out table heads, but there's no preview and no support for definition lists.
Can someone point me to the file(s) in Atom I'd need to work on to get:
a preview pane?
syntax highlighting for definition lists?

R Packages - What is the file 'zzz.R' used for?

I'm planning to condense some of my code into a package, and was looking at the source of a few published packages on CRAN as a guide. I notice many packages include the file R\zzz.R, so I presume there must be some convention surrounding this.
However, I cannot find any mention of zzz.R in the official Writing R Extensions guide. What is this file for, and do I need to include one in my package? Why is it named the way it is - why not zzzz.R?
It's a file where one usually puts actions on load of the package. It is tradition/convention that it's called zzz.R and could be called anything.R
You only need to include this if you want you package to do something out of the ordinary when it loads. Keep looking at what people put in there and you'll begin to get a sense of what they're used for.
This zzz.R file was also mentioned by Hadley Wickham in his book "R packages", at the bottom of "When you do need side-effects" section.
https://r-pkgs.org/Code.html#when-you-do-need-side-effects
If you use .onLoad(), consider using .onUnload() to clean up any side effects. By convention, .onLoad() and friends are usually saved in a file called R/zzz.R. (Note that .First.lib() and .Last.lib() are old versions of .onLoad() and .onUnload() and should no longer be used.)

cross-platform zip file creation

I'd like to create a zip archive from within R, and need maximal cross-platform compatibility, so I would prefer not to use a system("zip") command.
Within utils there's zip.file.extract (aka unzip), which uses [a lot of] c code, derived from zlib 1.1.3 within a file called dounzip.c I couldn't find any similar capabilities for creating zip files.
It's also tricky to construct a specific google query for "cran create zip" or equivalent!
Also, a tar will not suffice, I need to creating zip's to use as input for another set of non-R tools.
I'd appreciate any pointers?
cheers,
mark
As usual the amazing Omega Project for Statistical Computing is a valuable resource! Take a look at the Rcompression package and try, for example, something like:
?gzip
txt <- paste(rep("This is a string", 40), collapse = "\n")
v <- gzip(txt))
writeBin(v, "test.txt.zip")
HTH
I think the command gzfile() may also do what you're looking for. Also note that in the upcoming version 2.10.0 there are some enhancements to compression functions that may be relevant. (see https://svn.r-project.org/R/trunk/NEWS -- the svn server may ask you to accept a certificate)

Resources