npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gitbook-plugin-lanying-code-snippet

v1.1.12

Published

Embed github code snippets into gitbook

Readme

Embed Code Snippets into Gitbooks

Just fill in the repository name, class name and function name, this plugin will automatically search the github repository to generate code snippets that call this function。 Support C/C++/Java/Javascript/Objective-C languages.

Using this tag {% lanying_code_snippet repo="lanying-im-web",class="userManage",function="asyncRegister" %}{% endlanying_code_snippet %}, it will generate the code snippet as shown below:

Prerequisites

Joern needs to be installed.

You can install Joern according to this document

Installation

Add the following plugins to your book.json and run gitbook install

{ "plugins": ["lanying-code-snippet"] }

Usage

Configuration option can be set as an obj like:

{
    "plugins": [
        "lanying-code-snippet"
    ],
    "pluginsConfig": {
        "lanying-code-snippet": {
            "showLink": true,
            "reindent": true,
            "maxLine": 20,
            "maxSnippetCount": 10,
            "repositories": [
                {
                    "name":"lanying-im-web",
                    "url":"https://github.com/maxim-top/lanying-im-web.git",
                    "branch":"master"
                },
                {
                    "name":"lanying-im-android",
                    "url":"https://github.com/maxim-top/lanying-im-android.git",
                    "branch":"master",
                    "cacheDir": "../cache/lanying-im-android"
                }
            ]
        }
    }
}

Configuration

  • showLink=true Show a link below the embedded source back to the source file. Defaults to true
  • reindent=true Re-indent the lines given the line numbers. Defaults to true
  • maxLine=20 maximum number of lines each code snippet. Defaults to 20
  • maxSnippetCount=10 Maximum number of code snippets. Defaults to 10
  • repositories repositories are used to configure github repository information.
    • repositories[*].url is the url of github repository.
    • repositories[*].branch is the branch of github repository.
    • repositories[*].name is the name of github repository.
    • repositories[*].filter is used to filter which code to show. "call" - show code which call this function; "override" - show code which override this function. Defaults to "call|override", which will show calls and overrides.
    • repositories[*].cacheDir is the cache dir of github repository. If not set, a random directory under /tmp will be used。If set, the set directory will be used. if the language is Objective-C, cacheDir must be set.
  • Using the tag {% lanying_code_snippet repo="lanying-im-web",class="userManage",function="asyncRegister" %}{% endlanying_code_snippet %} to generate the code snippets, the repo is the name of github repository, must be one of repositories[*].name, the class is the class name, the function is the function name.

Styling the Link

Use a gitbook style override to adjust the style of the link. The class is .lanying-code-snippet-caption.

Objective-C language

If the code is write in Objective-C language, Xcode version less than 12 is needed. llvm2cpg is also needed. Must ensure the following command must execute successfully in the repo cache dir.

xcodebuild OTHER_CFLAGS='-fembed-bitcode -grecord-command-line -fno-inline-functions -fno-builtin' OTHER_CPLUSPLUSFLAGS='-fembed-bitcode -grecord-command-line -fno-inline-functions -fno-builtin' OTHER_LDFLAGS='-fembed-bitcode -grecord-command-line -fno-inline-functions -fno-builtin' clean build -quiet && llvm2cpg `find . -name '*.o'`

FAQ

  • When gitbook install report Error: spawn E2BIG, should rerun gitbook install command.