Browse Source

Move declarations to the corresponding namespaces

goanpeca 4 years ago
parent
commit
4ca82e9125
2 changed files with 46 additions and 33 deletions
  1. 35 22
      packages/notebook-extension/src/index.ts
  2. 11 11
      packages/notebook/src/notebooktools.ts

+ 35 - 22
packages/notebook-extension/src/index.ts

@@ -451,10 +451,16 @@ function activateNotebookTools(
   void services.nbconvert.getExportFormats().then(response => {
     if (response) {
       /**
-       * The exluded Cell Inspector Raw NbConvert Formats
+       * The excluded Cell Inspector Raw NbConvert Formats
        * (returned from nbconvert's export list)
        */
-      const rawFormtExclude = ['pdf', 'slides', 'script', 'notebook', 'custom'];
+      const rawFormatExclude = [
+        'pdf',
+        'slides',
+        'script',
+        'notebook',
+        'custom'
+      ];
       let optionValueArray: any = [
         [trans.__('PDF'), 'pdf'],
         [trans.__('Slides'), 'slides'],
@@ -465,9 +471,9 @@ function activateNotebookTools(
 
       // convert exportList to palette and menu items
       const formatList = Object.keys(response);
-      const formatLabels = getFormatLabels(translator);
+      const formatLabels = Private.getFormatLabels(translator);
       formatList.forEach(function(key) {
-        if (rawFormtExclude.indexOf(key) === -1) {
+        if (rawFormatExclude.indexOf(key) === -1) {
           const altOption = trans.__(key[0].toUpperCase() + key.substr(1));
           const option = formatLabels[key] ? formatLabels[key] : altOption;
           const mimeTypeValue = response[key].output_mimetype;
@@ -2084,23 +2090,6 @@ function populatePalette(
   });
 }
 
-/**
- * The default Export To ... formats and their human readable labels.
- */
-function getFormatLabels(translator?: ITranslator): { [k: string]: string } {
-  translator = translator || nullTranslator;
-  const trans = translator.load('jupyterlab');
-  return {
-    html: trans.__('HTML'),
-    latex: trans.__('LaTeX'),
-    markdown: trans.__('Markdown'),
-    pdf: trans.__('PDF'),
-    rst: trans.__('ReStructured Text'),
-    script: trans.__('Executable Script'),
-    slides: trans.__('Reveal.js Slides')
-  };
-}
-
 /**
  * Populates the application menus for the notebook.
  */
@@ -2172,7 +2161,7 @@ function populateMenus(
   exportTo.title.label = trans.__('Export Notebook As…');
   void services.nbconvert.getExportFormats().then(response => {
     if (response) {
-      const formatLabels: any = getFormatLabels(translator);
+      const formatLabels: any = Private.getFormatLabels(translator);
 
       // Convert export list to palette and menu items.
       const formatList = Object.keys(response);
@@ -2502,3 +2491,27 @@ namespace Private {
     }
   }
 }
+
+/**
+ * A namespace for private data.
+ */
+namespace Private {
+  /**
+   * The default Export To ... formats and their human readable labels.
+   */
+  export function getFormatLabels(
+    translator?: ITranslator
+  ): { [k: string]: string } {
+    translator = translator || nullTranslator;
+    const trans = translator.load('jupyterlab');
+    return {
+      html: trans.__('HTML'),
+      latex: trans.__('LaTeX'),
+      markdown: trans.__('Markdown'),
+      pdf: trans.__('PDF'),
+      rst: trans.__('ReStructured Text'),
+      script: trans.__('Executable Script'),
+      slides: trans.__('Reveal.js Slides')
+    };
+  }
+}

+ 11 - 11
packages/notebook/src/notebooktools.ts

@@ -38,17 +38,6 @@ import { NotebookPanel } from './panel';
 import { INotebookModel } from './model';
 import { INotebookTools, INotebookTracker } from './tokens';
 
-/**
- * A type alias for a readonly partial JSON tuples `[option, value]`.
- * `option` should be localized.
- *
- * Note: Partial here means that JSON object attributes can be `undefined`.
- */
-export declare type ReadonlyPartialJSONOptionValueArray = [
-  ReadonlyPartialJSONValue | undefined,
-  ReadonlyPartialJSONValue
-][];
-
 class RankedPanel<T extends Widget = Widget> extends Widget {
   constructor() {
     super();
@@ -276,6 +265,17 @@ export class NotebookTools extends Widget implements INotebookTools {
  * The namespace for NotebookTools class statics.
  */
 export namespace NotebookTools {
+  /**
+   * A type alias for a readonly partial JSON tuples `[option, value]`.
+   * `option` should be localized.
+   *
+   * Note: Partial here means that JSON object attributes can be `undefined`.
+   */
+  export type ReadonlyPartialJSONOptionValueArray = [
+    ReadonlyPartialJSONValue | undefined,
+    ReadonlyPartialJSONValue
+  ][];
+
   /**
    * The options used to create a NotebookTools object.
    */