Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add Atom's API docs to the Flight Manual #541

Merged
merged 69 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
786dd03
Create Rake tasks to download and split API data
lee-dohm Apr 30, 2019
8c9fe2d
Replicate class page title
lee-dohm Apr 30, 2019
3ec7b61
Add description and section headers
lee-dohm Apr 30, 2019
ca5643e
Add basic rendering of instance properties
lee-dohm May 13, 2019
e2ad79e
Add summary and description sections to methods
lee-dohm May 22, 2019
c2d23c5
Add class and method reference linking
lee-dohm May 24, 2019
4b98ceb
Fix arguments and return value tables
lee-dohm Jun 10, 2019
1c85628
Create a content column in API docs so that things flow properly
lee-dohm Jun 10, 2019
6ccef21
Add atom-api.json files from v1.0.0 to present (v1.38.2)
jasonrudolph Jun 25, 2019
069d94d
:fire: Remove temporary Rake task for downloading historical API files
jasonrudolph Jun 25, 2019
0984b6f
Teach split_api_json Rake task to process files in data/apis-by-version
jasonrudolph Jun 25, 2019
8bc9122
Add colon indicators to properties
lee-dohm Jun 25, 2019
42c10c6
Move JSON splitting from Rake to Gulp
jasonrudolph Jun 26, 2019
8595b00
:fire: Remove unused arg
jasonrudolph Jun 26, 2019
98f177e
Fix "stdout maxBuffer exceeded" error when building site
jasonrudolph Jun 26, 2019
3d25e59
Gracefully ignore any non JSON files in data/apis-by-version dir
jasonrudolph Jun 26, 2019
76a088c
Signal completion of "extract_api_docs_data" task
jasonrudolph Jun 26, 2019
22558dd
Avoid long periods of no output from `run_proofer` task
jasonrudolph Jun 27, 2019
2c08ae9
Merge pull request #537 from atom/jr/api-docs
jasonrudolph Jun 27, 2019
399c712
Merge remote-tracking branch 'origin/master' into api-docs
jasonrudolph Jun 27, 2019
189c8bd
Linkify instance property names
jasonrudolph Jun 27, 2019
a9df28e
Toggle display of instance property description onclick
jasonrudolph Jun 27, 2019
8e119a3
Honor URL hash to display instance property description
jasonrudolph Jun 27, 2019
6cdbad6
Linkify method names and toggle details onclick
jasonrudolph Jun 27, 2019
4649175
Render class-level examples
jasonrudolph Jun 27, 2019
5dfe19b
Fix the HTMLProofer build failures
jasonrudolph Jun 27, 2019
aeee307
Begin populating search index with API docs
jasonrudolph Jul 1, 2019
74475a7
Fix URL to API docs in search index
jasonrudolph Jul 1, 2019
b0526cd
Fix ellipsis
jasonrudolph Jul 1, 2019
fb77ad9
Add instance properties to search index
jasonrudolph Jul 1, 2019
4599da9
Add class methods to search index
jasonrudolph Jul 1, 2019
0a417a8
Add classes to search index
jasonrudolph Jul 1, 2019
f3cc52e
:art: Refactor to reduce duplication
jasonrudolph Jul 1, 2019
4685379
Add a section to the table of contents for latest version class names
lee-dohm Jul 1, 2019
4a78c06
:art: DRY it up and modularize
lee-dohm Jul 2, 2019
8416455
Point the API links to the hardcoded latest version
lee-dohm Jul 2, 2019
387eeee
Fix the latest version number calculation
lee-dohm Jul 2, 2019
b8b8986
Add helpful redirects for API-related paths
jasonrudolph Jul 2, 2019
7ece9a2
:art: Reduce duplication in compilation rules
jasonrudolph Jul 2, 2019
3451c8d
Remove hardcoded class name
jasonrudolph Jul 2, 2019
de1e02a
:art: Refactor redirect definition logic for API-related paths
jasonrudolph Jul 2, 2019
2bcdb3c
:art: Rename file to better reflect its use
jasonrudolph Jul 2, 2019
355e99c
Merge remote-tracking branch 'origin/master' into api-docs
jasonrudolph Jul 3, 2019
566ae12
Render API docs for methods where the "section" is null
jasonrudolph Jul 3, 2019
c6f7905
Don't show duplicate sections
jasonrudolph Jul 3, 2019
b521ac6
Include class methods in API doc sections
jasonrudolph Jul 3, 2019
ba691d3
Fix compilation of non-API pages
Jul 4, 2019
d8470a0
Honor selected version during search
Jul 5, 2019
b14caf0
Keep URL up to date when user selects a new version in the search page
Jul 5, 2019
373fa93
Fix warnings in search.js
Jul 5, 2019
9c457cd
Redirect to the versioned API page when selecting a new version
Jul 5, 2019
ccef5c1
Render TOC based on the selected version when viewing an API page
Jul 5, 2019
b3e6add
Move API docs functionality from search.js to api-docs.js
Jul 15, 2019
60234aa
Label "Public" classes as "Essential"
jasonrudolph Jul 15, 2019
5a0f390
Add label to denote optional arguments
jasonrudolph Jul 15, 2019
73b0e94
Add syntax highlighting for code examples in API docs
Jul 16, 2019
01d81c7
Start on grouping methods by their visibility
Jul 16, 2019
128cf11
Fix styling of message to match atom.io
jasonrudolph Jul 16, 2019
1625298
Fix text to match atom.io and adjust heading level
jasonrudolph Jul 16, 2019
f568383
:art: Move method
jasonrudolph Jul 16, 2019
0b7fde1
Align version select box and search input field
jasonrudolph Jul 16, 2019
f6c1ff9
Prefix version label with 'v'
jasonrudolph Jul 16, 2019
b4c3dc0
Don't hard-wrap when encountering newlines
Jul 17, 2019
9f85a96
Replace input type from "search" to "text"
Jul 17, 2019
1ec6b44
Remove commented-out code
lee-dohm Jul 17, 2019
47cbabf
Specify which version of Node to use
lee-dohm Jul 17, 2019
92981c2
Inline functions that aren't used outside of temp.rb
lee-dohm Jul 17, 2019
9ee89a4
Merge 'origin/master' into api-docs
jasonrudolph Jul 25, 2019
7b48541
Add data/apis-by-version/v1.39.1.json
jasonrudolph Jul 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ atom.epub
atom-kf8.epub
atom.mobi
/images/
content/api
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ruby '2.4.2'
# essential
gem 'nanoc', '~> 4.7'
gem 'nanoc-conref-fs', '~> 0.7'
gem 'nanoc-redirector', '~> 0.2'

# rendering
gem 'nanoc-html-pipeline', '~> 0.3'
Expand All @@ -12,6 +13,8 @@ gem 'html-pipeline-rouge_filter', '~> 1.0'
gem 'extended-markdown-filter', '~> 0.4'
gem 'html-pipeline-asciidoc_filter', '~> 1.5'
gem 'github-markdown', '~> 0.6.9'
gem 'kramdown'
gem 'kramdown-parser-gfm'

gem 'activesupport', '~> 4.2'
gem 'rake'
Expand Down
10 changes: 9 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ GEM
yell (~> 2.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
kramdown (2.1.0)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.0)
mercenary (0.3.6)
method_source (0.9.0)
Expand All @@ -75,6 +78,8 @@ GEM
nanoc-html-pipeline (0.3.5)
html-pipeline (~> 2.0)
nanoc (>= 3.1, < 5.0)
nanoc-redirector (0.3.0)
nanoc (~> 4.9.0)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
parallel (1.12.1)
Expand Down Expand Up @@ -109,9 +114,12 @@ DEPENDENCIES
html-pipeline-asciidoc_filter (~> 1.5)
html-pipeline-rouge_filter (~> 1.0)
html-proofer (~> 3.7)
kramdown
kramdown-parser-gfm
nanoc (~> 4.7)
nanoc-conref-fs (~> 0.7)
nanoc-html-pipeline (~> 0.3)
nanoc-redirector (~> 0.2)
pry
pry-coolline
rake
Expand All @@ -120,4 +128,4 @@ RUBY VERSION
ruby 2.4.2p198

BUNDLED WITH
1.16.3
2.0.2
10 changes: 9 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
require "find"
require 'fileutils'
require 'json'
require 'open3'
require 'open-uri'

task :default => [:test]

task :clean_api do
FileUtils.rm_rf('content/api')
end

desc "Remove the tmp dir"
task :remove_tmp_dir do
FileUtils.rm_r('tmp') if File.exist?('tmp')
Expand Down Expand Up @@ -31,8 +38,9 @@ task :run_proofer do
# Ignore platform switcher hash URLs
platform_hash_urls = ['#platform-mac', '#platform-windows', '#platform-linux', '#platform-all']
HTMLProofer.check_directory("./output", {
:file_ignore => [%r(/output/api/)],
:url_ignore => platform_hash_urls,
:typhoeus => { :ssl_verifypeer => false }
:typhoeus => { :ssl_verifypeer => false },
}).run
end

Expand Down
39 changes: 34 additions & 5 deletions Rules
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#!/usr/bin/env ruby

require 'extended-markdown-filter'
require 'nanoc-redirector'
require_relative 'lib/filters/api_json_filter'
require_relative 'lib/redirects'

preprocess do
versions = @items.find_all('/api/*/*.json').map { |item| item.identifier.to_s.split('/')[2] }.uniq
versions.each do |version|
json_items_for_version = @items.find_all("/api/#{version}/*.json")
class_names_for_version = json_items_for_version.map { |item| File.basename(item.identifier, '.json') }
first_class_name_for_version = class_names_for_version.sort.first
create_item_with_redirect source: "/api/#{version}/index.md", destination: "/api/#{version}/#{first_class_name_for_version}"

@items.create('', {:api_version => version.tr('v', '')}, "/search/#{version}.json")
end

create_item_with_redirect source: '/api/index.md', destination: '/api/latest'
create_item_with_redirect source: '/api/latest.md', destination: "/api/v#{latest_atom_version_number}"
end

compile '/api/**/*.md' do
filter :redirect_to, { :redirect_to => @item[:redirect_to] }
end

compile '/index.html' do
filter :erb
Expand Down Expand Up @@ -28,13 +50,24 @@ compile '**/*.md' do
layout '/article.html'
end

compile '/api/**/*.json' do
class_name = File.basename(item.identifier.without_ext)
version = File.basename(File.dirname(item.identifier))

filter :api_json, class_name: class_name, version: version
filter :erb
layout '/api-class.html', :locals => { :version => version.tr('v', '') }
end

compile '/search.html' do
filter :erb
layout '/toc.html'
end

compile '/search.json' do
compile '/search/*.json' do
filter :erb
layout '/search.json'
write item.identifier
end

passthrough '/**/*.jpg'
Expand All @@ -43,10 +76,6 @@ passthrough '/**/*.png'
passthrough '/**/*.gif'
passthrough '/CNAME'

route '/search.json' do
'/search.json'
end

route '**/*' do
if item.binary?
item.identifier.chop + (item[:extension] ? '.' + item[:extension] : '')
Expand Down
50 changes: 50 additions & 0 deletions assets/javascripts/api-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
(function() {
if (isApiDocsPage()) {
$(document).on("click", ".js-api-name", function(e) {
e.preventDefault();
toggleApiEntry($(this).attr("href"));
return false;
});

$(document).ready(function() {
if (window.location.hash) {
toggleApiEntry(window.location.hash);
}

$("#documents-search-versions").change(function() {
const components = window.location.pathname.split("/");
if (!components[components.length - 1]) {
// Pop trailing slash off
components.pop();
}
const page = components.pop();
const version = this.value;
const { hash } = window.location;
window.location.replace(`/api/v${version}/${page}${hash}`);
});
});

$(window).on("hashchange", function() {
toggleApiEntry(window.location.hash);
});
}

function toggleApiEntry(apiEntryId) {
const entry = $(apiEntryId);
const extendedContainer = entry.parents(".extended-methods-container");
if (extendedContainer.length) {
extendedContainer.addClass("show");
}

if (entry.hasClass("expanded")) {
entry.removeClass("expanded");
} else {
entry.addClass("expanded");
window.history.replaceState("", "", apiEntryId); // update url hash w/o adding history
}
}

function isApiDocsPage() {
return window.location.pathname.startsWith("/api/");
}
})();
179 changes: 0 additions & 179 deletions assets/javascripts/jquery.lunr.search.js

This file was deleted.

Loading