Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Demo multiple lang doc #1163

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
23 changes: 23 additions & 0 deletions docs/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<html>
<head>
<title>Page not found - Promptflow</title>
<script>
function checkPath() {
// Redirect url to default python version
// Example current path: /promptflow/how-to-guides/quick-start.html
const currentPath = window.location.pathname;
const raw404 = "https://microsoft.github.io/promptflow/404NotFound.html";
// No language prefer in the url, fall back to python
// Example path after fall back: /promptflow/python/how-to-guides/quick-start.html
if (currentPath.includes('/promptflow') && !currentPath.match(/promptflow\/(python|csharp|javascript)/gi)){
window.location.href = window.location.href.replace("/promptflow", "/promptflow/python");
} else if (window.location.href !== raw404){
window.location.href = raw404;
}
}
</script>
</head>
<body onload="checkPath()">
</body>
</html>
```
20 changes: 20 additions & 0 deletions docs/404NotFound.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<head>
<title>Page not found - Promptflow</title>
</head>
<body>
<div class="container">
<h1>404</h1>
<p><strong>File not found</strong></p>

<p>
The site configured at this address does not
contain the requested file.
</p>
<p>
<a href="https://microsoft.github.io/promptflow">Back to the homepage</a>
</p>

</div>
</body>
</html>
8 changes: 8 additions & 0 deletions docs/csharp/how-to-guides/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# How-to Guides
## This is the CSharp index

```{toctree}
:hidden:
:maxdepth: 1
manage-connections
```
1 change: 1 addition & 0 deletions docs/csharp/how-to-guides/manage-connections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Manage Connections (C#)
3 changes: 3 additions & 0 deletions docs/csharp/how-to-guides/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Quick Start
## This is the CSharp quick start
### balabalabala
14 changes: 14 additions & 0 deletions docs/csharp/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# C# index


```{toctree}
:hidden:
:maxdepth: 1
how-to-guides/quick-start
```

```{toctree}
:hidden:
:maxdepth: 1
how-to-guides/index
```
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta http-equiv="Refresh" content="0; url='https://microsoft.github.io/promptflow/python/index.html'" />
8 changes: 8 additions & 0 deletions docs/js/how-to-guides/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# How-to Guides
## This is the JS index

```{toctree}
:hidden:
:maxdepth: 1
manage-connections
```
1 change: 1 addition & 0 deletions docs/js/how-to-guides/manage-connections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Manage Connections (js)
3 changes: 3 additions & 0 deletions docs/js/how-to-guides/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Quick Start
## This is the JS quick start
### balabalabala
13 changes: 13 additions & 0 deletions docs/js/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# JS index

```{toctree}
:hidden:
:maxdepth: 1
how-to-guides/quick-start
```

```{toctree}
:hidden:
:maxdepth: 1
how-to-guides/index
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This contributing guide doc should still keep at root, links in it might need to change

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/docs/_static/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ window.onload = () => {
};
};

if (window.location.pathname === "/promptflow/" || window.location.pathname === "/promptflow/index.html") {
if (DOCUMENTATION_OPTIONS.pagename === "index") {
// This is used to control homepage background
let observer = new MutationObserver(function(mutations) {
const dark = document.documentElement.dataset.theme == 'dark';
Expand Down
18 changes: 18 additions & 0 deletions scripts/docs/_static/switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"name": "Python",
"version": "python",
"url": "https://promptflow-reference.azurewebsites.net/_build/python/",
"preferred": true
},
{
"name": "JavaScript",
"version": "javascript",
"url": "https://promptflow-reference.azurewebsites.net/_build/javascript/"
},
{
"name": "C#",
"version": "csharp",
"url": "https://promptflow-reference.azurewebsites.net/_build/csharp/"
}
]
12 changes: 11 additions & 1 deletion scripts/docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -- Path setup --------------------------------------------------------------
import os
import sys

# -- Project information -----------------------------------------------------
Expand Down Expand Up @@ -74,6 +75,11 @@
html_show_sourcelink = False

# Define the json_url for our version switcher.
# json_url = "https://raw.githubusercontent.com/microsoft/promptflow/main/scripts/docs/_static/switcher.json"
json_url = "https://raw.githubusercontent.com/brynn-code/promptflow-page/main/switcher.json"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to azure blob .


# Define the version we use for matching in the version switcher.
version_match = os.environ.get("DOC_VERSION") or "JavaScript"

html_theme_options = {
"github_url": "https://github.com/microsoft/promptflow",
Expand All @@ -92,8 +98,12 @@
"use_edit_page_button": True,
"show_toc_level": 1,
"navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
"navbar_center": ["navbar-nav"],
"navbar_center": ["version-switcher", "navbar-nav"],
# "announcement": "Test our announcement here.",
"switcher": {
"json_url": json_url,
"version_match": version_match,
},
"show_nav_level": 1,
}

Expand Down
20 changes: 19 additions & 1 deletion scripts/docs/doc_generation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,25 @@ if($WarningAsError){
if($BuildLinkCheck){
$BuildParams.Add("-blinkcheck")
}
sphinx-build $TempDocPath $OutPath -c $ScriptPath $BuildParams | Tee-Object -FilePath $SphinxBuildDoc
$Env:DOC_VERSION = "Python"
$PYTHON_DOC = [System.IO.Path]::Combine($TempDocPath, "python")
$PYTHON_DOC_OUT = [System.IO.Path]::Combine($OutPath, "python")
sphinx-build $PYTHON_DOC $PYTHON_DOC_OUT -c $ScriptPath $BuildParams | Tee-Object -FilePath $SphinxBuildDoc
$Env:DOC_VERSION = "C#"
$CSHARP_DOC = [System.IO.Path]::Combine($TempDocPath, "csharp")
$CSHARP_DOC_OUT = [System.IO.Path]::Combine($OutPath, "csharp")
sphinx-build $CSHARP_DOC $CSHARP_DOC_OUT -c $ScriptPath $BuildParams | Tee-Object -FilePath $SphinxBuildDoc
$Env:DOC_VERSION = "Javascript"
$JS_DOC = [System.IO.Path]::Combine($TempDocPath, "js")
$JS_DOC_OUT = [System.IO.Path]::Combine($OutPath, "js")
sphinx-build $JS_DOC $JS_DOC_OUT -c $ScriptPath $BuildParams | Tee-Object -FilePath $SphinxBuildDoc
# Copy 404 files.
[string] $404Path = [System.IO.Path]::Combine($DocPath, "404.html")
[string] $Raw404Path = [System.IO.Path]::Combine($DocPath, "404NotFound.html")
[string] $IndexPath = [System.IO.Path]::Combine($DocPath, "index.html")
Copy-Item -Path $404Path -Destination $OutPath -Force
Copy-Item -Path $Raw404Path -Destination $OutPath -Force
Copy-Item -Path $IndexPath -Destination $OutPath -Force
$buildWarningsAndErrors = Select-String -Path $SphinxBuildDoc -Pattern $WarningErrorPattern

Write-Host "Clean path: $TempDocPath"
Expand Down