1// Copyright 2019 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5import 'dart:io'; 6 7/// This changes the DocSetPlatformFamily key to be "dartlang" instead of the 8/// name of the package (usually "flutter"). 9/// 10/// This is so that the IntelliJ plugin for Dash will be able to go directly to 11/// the docs for a symbol from a keystroke. Without this, flutter isn't part 12/// of the list of package names it searches. After this, it finds the flutter 13/// docs because they're declared here to be part of the "dartlang" family of 14/// docs. 15/// 16/// Dashing doesn't have a way to configure this, so we modify the Info.plist 17/// directly to make the change. 18void main(List<String> args) { 19 final File infoPlist = File('flutter.docset/Contents/Info.plist'); 20 String contents = infoPlist.readAsStringSync(); 21 22 // Since I didn't want to add the XML package as a dependency just for this, 23 // I just used a regular expression to make this simple change. 24 final RegExp findRe = RegExp(r'''(\s*<key>DocSetPlatformFamily</key>\s*<string>)[^<]+(</string>)''', multiLine: true); 25 contents = contents.replaceAllMapped(findRe, (Match match) { 26 return '${match.group(1)}dartlang${match.group(2)}'; 27 }); 28 infoPlist.writeAsStringSync(contents); 29} 30