Code Monkey home page Code Monkey logo

docflip's Introduction

#DocFlip DocFlip is a Chrome extension that makes it easy to switch between the Mac and iOS versions of Apple's Developer Library documentation. It adds a 'flip' link to the header of any supported page: Screenshot of the DocFlip link Clicking the link will take you to the corresponding document in the other platform's Developer Library.

#Installation Install DocFlip from the Chrome Web Store here.

#Supported Pages DocFlip should support reference docs for all classes and protocols that are present on both Mac and iOS. This includes items with the same name on both platforms like NSString and items that have the same name but different prefixes on each platform like NSApplicationDelegate and UIApplicationDelegate.

No flip link is shown on pages that aren't supported (either because the item doesn't exist on the other platform or because of a bug).

#I found a page where DocFlip doesn't work! Apple's docs have a wide and sometimes-unpredictable variety of naming and URL schemes, which makes it difficult to support and test everything. If you find a page where DocFlip doesn't work but shouldn't, add a GitHub issue and I'll try to add support. Or, if you're feeling generous (or impatient), you can add support yourself. Follow the below directions to create and add your guess and submit a pull request.

#Adding Support For Additional Pages ##Overview DocFlip finds corresponding pages by iterating over an array of 'guesses' and testing each one until it finds one that works. Guesses are just regex replacements that modify the URL of the page, so each guess contains a pattern and a replacement. If the current URL matches the pattern, the replacement is made and the resultant page is tested for existence with an Ajax HEAD request. If it exists, the DocFlip link adopts this URL.

##Adding Guesses Guesses are stored in the guesses array, which is defined near the beginning of docflip.js. They usually come in pairs: one to go from the Mac page to the iOS page and one to go from iOS to Mac. Here's an example pair of guesses:

// Protocol references for protocols that are present on both platforms but have different prefixes, like NSTextInput.
{pattern: /\/library\/mac\/documentation\/Cocoa\/Reference\/ApplicationKit\/Classes\/NS/g,
 replacement: '/library/ios/documentation/uikit/reference/UI'},
{pattern: /\/library\/ios\/documentation\/(?:uik|UIK)it\/[Rr]eference\/UI(\w+)_[Cc]lass\//g,
 replacement: '/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NS$1_Class/'}

Both of these are for classes that are present on both platforms but have different prefixes. The first one goes from Mac pages to iOS pages, and the second one goes from iOS to Mac.

##Guidelines

  • Try to make your pattern reasonably specific so that it's only tried for pages where it could potentially work. For example, if you're writing a guess for protocol references make sure its pattern is not matched by class reference pages.
  • Order guesses based on how likely they are to be correct. DocFlip tries guesses sequentially and stops when it reaches one that works, so putting guesses that are correct more often first improves performance.
  • Add a comment that explains what your guess does and notes a page where it is works. See the existing guesses for examples.

Thanks for contributing!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.