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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tourist-core

v0.6.0

Published

An implementation of Tourist in node.js.

Downloads

15

Readme

Tourist

Tourist is a new approach to documentation that allows programmers to explain low-level technical details of a system while simultaneously providing the context of how those details fit into the broader architecture. It lets programmers document code in the same way that they would explain it in person: by walking the consumer step-by-step through the important parts of a codebase.

A tour is a series of locations throughout a codebase, along with accompanying prose that explains the importance each location in turn.

A maintainer of a project can more effectively introduce newcomers to the project by setting up one or more tours for the codebase that highlight the relevant functional components. A person implementing a complex feature or workflow can use a tour to solicit feedback from other people who are familiar to the codebase, but not that particular logical flow.

Getting Started

As of now, Tourist only available as a node module and an associated extension for Visual Studio Code. The extension can be found at tourist-doc/tourist-vscode. We plan on releasing a command-line tool in the near future that will provide an API that other edtiors can more easily use.

Building

The Tourist library can be built with

npm run build

and tested with

npm test

Make sure you've npm installed the appropriate dependencies.

Library Usage

The main way to interact with the Tourist library is via the Tourist class.

import { Tourist } from "tourist";
const tourist = new Tourist();

Alternatively, if you already have a serialized version of a tourist instance, you can construct a live instance with

const str = tourist.serialize();
// ...
const newTourist = Tourist.deserialize(str);

Once you have a tourist instance, the first thing to do is set up some repository mappings. Repository mappings are a simple abstraction that tourist uses to make tours more portable -- rather than specify that a tour goes to /this/absolute/path/file.txt, you can instead specify that a tour stop is in file.txt in the foo repository. Each user then individually tells tourist where foo is

tourist.mapConfig("foo", "/this/absolute/path");

With mappings set, you can run

const tourFile = tourist.init("My First Tour");

to create a new tour file, and then you're off to the races. You can use commands like add, remove, edit, move, and scramble to manipulate tour stops, and at the end you can use resolve to get a tour with absolute paths that are easy for editors to understand.

Refreshing a Tour

By default, a tour is linked to a particular git commit. (Actually, it's linked to one commit per repository that the tour visits, but for simplicity we'll assume your first tour will only touch one repository.) As your files change and your code evolves, eventually a tour of an old version will stop being very meaningful. Tourist makes it easy to update an old tour to a new commit, using the refresh command.

Refresh is pretty smart under the covers, but its basic approach is to look at the file changes between the tour's stable commit and the latest commit in the repository and compute how each line might have changed. Usually it's as simple as counting up the number of lines that were added above the line, and subtracting the number of lines that was deleted, but in reality git's diff output is a little more complicated than that. Refreshes also handle file renaming, to the extent that git does.

Occasionally, refreshing a stop won't be possible. This is usually because the target line (or even file) has been deleted or changed beyond recognition. In these cases, the tour stop would likely need to be completely changed anyway. When tourist fails to refresh a stop, the line of the stop is set to 0, and the file path is set to "". When a broken stop like this is resolved, the result will be a BrokenStop with just a title and a body.

At the end of the refresh, the commit in the tour file is updated to the currently checked out commit.