-
Notifications
You must be signed in to change notification settings - Fork 32
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
DocGenerator - Search UI integration #1691
Merged
palaciosjeremias
merged 8 commits into
dev-1600-docgenerator-UI
from
dev-1681-docgenerator-search_ui-integration
Aug 9, 2021
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b833111
Search-UI implementation. First approach
MiguelazoDS a1775d5
Added example documentation headers
MiguelazoDS 5b2cde1
Fix indentation, remove unused variables and modules
MiguelazoDS 3181b84
Added module to index data into elasticsearch
MiguelazoDS 8005c9d
Fixed some typos
MiguelazoDS 8e2425b
Search works with partial words and highlights the result
MiguelazoDS c7c68e8
Added module to lib folder, added new module to requirements.txt file
MiguelazoDS 45c8911
Code review fixes
MiguelazoDS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,11 @@ | |
import re | ||
import json | ||
import yaml | ||
import ast | ||
from lib.Config import Config | ||
from lib.CodeParser import CodeParser | ||
from lib.Sanity import Sanity | ||
from lib.Utils import clean_folder | ||
from lib.IndexData import IndexData | ||
import warnings | ||
import logging | ||
import argparse | ||
|
@@ -26,7 +26,7 @@ | |
class DocGenerator: | ||
""" | ||
brief: Main class of DocGenerator tool. | ||
It´s in charge of walk every test file, and every group file to dump the parsed documentation | ||
It´s in charge of walk every test file, and every group file to dump the parsed documentation. | ||
""" | ||
def __init__(self, config): | ||
self.conf = config | ||
|
@@ -41,7 +41,7 @@ def __init__(self, config): | |
|
||
def is_valid_folder(self, path): | ||
""" | ||
brief: Checks if a path should be ignored because its in the ignore list. | ||
brief: Checks if a path should be ignored because it is in the ignore list. | ||
args: | ||
- "path (str): Folder location to be controlled" | ||
returns: "boolean: False if the path should be ignored. True otherwise." | ||
|
@@ -158,7 +158,7 @@ def create_test(self, path, group_id): | |
|
||
def parse_folder(self, path, group_id): | ||
""" | ||
brief: Search in a specific folder to parse possible group files and each test file | ||
brief: Search in a specific folder to parse possible group files and each test file. | ||
args: | ||
- "path (string): The path of the folder to be parsed." | ||
- "group_id (string): The id of the group where the new elements belong." | ||
|
@@ -207,6 +207,8 @@ def start_logging(folder, debug_level=logging.INFO): | |
parser.add_argument('-v', help="Print version", action='store_true', dest="version") | ||
parser.add_argument('-t', help="Test configuration", action='store_true', dest='test_config') | ||
parser.add_argument('-d', help="Enable debug messages.", action='count', dest='debug_level') | ||
parser.add_argument('-i', help="Indexes the data to elasticsearch.", dest='index_name') | ||
parser.add_argument('-l', help="Indexes the data and launch the application.", dest='launch_app') | ||
args = parser.parse_args() | ||
|
||
if args.debug_level: | ||
|
@@ -221,6 +223,14 @@ def start_logging(folder, debug_level=logging.INFO): | |
elif args.sanity: | ||
sanity = Sanity(Config(CONFIG_PATH)) | ||
sanity.run() | ||
elif args.index_name: | ||
indexData=IndexData(args.index_name, Config(CONFIG_PATH)) | ||
indexData.run() | ||
elif args.launch_app: | ||
indexData=IndexData(args.launch_app, Config(CONFIG_PATH)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
indexData.run() | ||
os.chdir("Search-UI") | ||
os.system("ELASTICSEARCH_HOST=http://localhost:9200 npm start") | ||
else: | ||
docs = DocGenerator(Config(CONFIG_PATH)) | ||
docs.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/netlify-lambda | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
This is a Netlify Function that proxies our Elasticsearch instance. | ||
*/ | ||
import fetch from "node-fetch"; | ||
import https from "https"; | ||
import http from "http"; | ||
|
||
// Don't do this in production, this is in place to aid with demo environments which have self-signed certificates. | ||
const httpsAgent = new https.Agent({ | ||
rejectUnauthorized: false | ||
}); | ||
|
||
const httpAgent = new http.Agent(); | ||
|
||
exports.handler = function(event, context, callback) { | ||
const host = process.env.ELASTICSEARCH_HOST; | ||
const agent = host.startsWith("http:") ? httpAgent : httpsAgent; | ||
|
||
fetch(`${host}/qa-doc/_search`, { | ||
method: "POST", | ||
headers: { "content-type": "application/json" }, | ||
body: event.body, | ||
agent | ||
}) | ||
.then(response => response.text().then(body => [response, body])) | ||
.then(([response, body]) => { | ||
callback(null, { | ||
statusCode: response.status, | ||
body: body | ||
}); | ||
}) | ||
.catch(e => { | ||
console.error(e); | ||
callback(null, { | ||
statusCode: 500, | ||
body: `An error occurred: ${e}` | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[build] | ||
functions = "netlify-lambda" | ||
publish = "build/" | ||
command = "npm run build" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style: Use white spaces around "="
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done