@@ -1679,7 +1679,7 @@ The shortcode takes a regular expression for matching placeholder names.
1679
1679
Use the `code- placeholder- key` shortcode to format the placeholder names in
1680
1680
text that describes the placeholder-- for example:
1681
1681
1682
- ```
1682
+ ```markdown
1683
1683
{{% code- placeholders " DATABASE_NAME|USERNAME|PASSWORD_OR_TOKEN|API_TOKEN|exampleuser@influxdata.com" % }}
1684
1684
```sh
1685
1685
curl -- request POST http:// localhost:8086 / write? db=DATABASE_NAME \
@@ -1703,3 +1703,64 @@ InfluxDB API documentation when documentation is deployed.
1703
1703
Redoc generates HTML documentation using the InfluxDB `swagger.yml` .
1704
1704
For more information about generating InfluxDB API documentation, see the
1705
1705
[API Documentation README ](https:// github.com/ influxdata/ docs- v2/ tree/ master/ api- docs# readme).
1706
+
1707
+ # # JavaScript in the documentation UI
1708
+
1709
+ The InfluxData documentation UI uses JavaScript with ES6 + syntax and
1710
+ `assets/ js/ main.js` as the entry point to import modules from
1711
+ `assets/ js` .
1712
+ Only `assets/ js/ main.js` should be imported in HTML files.
1713
+
1714
+ `assets/ js/ main.js` registers components and initializes them on page load.
1715
+
1716
+ If you' re adding UI functionality that requires JavaScript, follow these steps:
1717
+
1718
+ 1 . In your HTML file , add a `data- component` attribute to the element that
1719
+ should be initialized by your JavaScript code. For example:
1720
+
1721
+ ```html
1722
+ < div data- component = " my-component" >< / div>
1723
+ ```
1724
+
1725
+ 2 . Following the component pattern, create a single- purpose JavaScript module
1726
+ (`assets/ js/ components/ my- component.js` )
1727
+ that exports a single function that receives the component element and initializes it.
1728
+ 3 . In `assets/ js/ main.js` , import the module and register the component to ensure
1729
+ the component is initialized on page load.
1730
+
1731
+ # ## Debugging JavaScript
1732
+
1733
+ To debug JavaScript code used in the InfluxData documentation UI :
1734
+
1735
+ 1 . In your JavaScript module, import debug helpers from `assets/ js/ utils/ debug- helpers.js` .
1736
+ These helpers provide breakpoints and console logging as a workaround for
1737
+ Hugo' s lack of source map support in the asset pipeline.
1738
+ 2 . Insert debug statements by calling the helper functions in your code-- for example:
1739
+
1740
+ ```js
1741
+ import { debugLog, debugBreak, debugInspect } from ' ./utils/debug-helpers.js' ;
1742
+
1743
+ const data = debugInspect(someData, ' Data' );
1744
+ debugLog(' Processing data' , ' myFunction' );
1745
+
1746
+ function processData() {
1747
+ // Add a breakpoint that works with DevTools
1748
+ debugBreak();
1749
+
1750
+ // Your existing code...
1751
+ }
1752
+ ```
1753
+
1754
+ 3 . Start Hugo in development mode-- for example:
1755
+
1756
+ ```bash
1757
+ yarn hugo server
1758
+ ```
1759
+
1760
+ 4 . In VS Code, go to Run > Start Debugging, and select the " Debug Docs (console-based)" configuration.
1761
+
1762
+ Your system uses the configuration in `launch.json` to launch the site in Chrome
1763
+ and attach the debugger to the Developer Tools console.
1764
+
1765
+ Make sure to remove the debug statements before merging your changes.
1766
+ The debug helpers are designed to be used in development and should not be used in production.
0 commit comments