# d360_makesite

A Python CLI tool that consolidates downloaded Document360 documentation into a single HTML file and a single Markdown file.

## 1. Read the TOC

Read the table of contents generated by `d360_getsitenav.py`. It contains links in this general format:

```html
<li xmlns="http://www.w3.org/1999/xhtml">
  <a href="/docs/creating-a-sandbox-project">
    <span>Creating a sandbox project</span>
  </a>
</li>
```

### 1.1. Parse the links

The local `docs` folder contains files like `creating-a-sandbox-project.html`. Convert TOC links to relative file paths.

## 2. Read each page

### 2.1. Extract the title

From each page, extract the title using:

```css
#main-content > d360-article-header > div.d-flex.justify-content-between.align-items-center.mb-3 > h1
```

or the equivalent XPath:

```xpath
//*[@id="main-content"]/d360-article-header/div[1]/h1
```

Example HTML:

```html
<h1 _ngcontent-serverapp-c2150518017="" class="article-title"> Creating a sandbox project </h1>
```

### 2.2. Extract the content

Extract the main article content using:

```css
#articleContent
```

or the equivalent XPath:

```xpath
//*[@id="articleContent"]
```

Example HTML:

```html
<article _ngcontent-serverapp-c3082681425="" id="articleContent" class="block-article">
  <p data-block-id="8963fc1c-9933-4271-aeba-f2278090bd13">
    <strong>Plans supporting for creating a Sandbox project</strong>
  </p>
  <div contenteditable="false" translate="no" data-snippet="Ent plan supported" class="fr-deletable" id="blocksnippet">
    <table style="width: 100%;">
      <thead>
        <tr>(...)</tr>
      </thead>
    </table>
  </div>
</article>
```

## 3. Compile a complete document

### 3.1. HTML document

Generate a complete HTML file with this structure:

```html
<html>
  <body>
    <aside>
      <nav>
        <!-- original nav with relative links -->
      </nav>
    </aside>
    <main>
      <div id="<!-- original filename without .html -->">
        <h1>...</h1>
        <!-- title -->
        <article>...</article>
        <!-- article content -->
      </div>
      <!-- repeat for each page -->
    </main>
  </body>
</html>
```

### 3.2. Markdown document

Convert the compiled HTML document to Markdown using `html2text`.