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

Fix platform type #1681

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .gitlab/ci/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variables:
CURRENT_BRANCH_NAME: $INFRA_BRANCH
CURRENT_BRANCH_NAME: "append-graph-to-content-docs"

include:
- file: "/.gitlab/ci/content-docs/.gitlab-ci.yml"
ref: $INFRA_BRANCH
ref: "append-graph-to-content-docs"
project: "${CI_PROJECT_NAMESPACE}/infra"
16 changes: 12 additions & 4 deletions content-repo/gen_pydocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@


class DemistoMarkdownRenderer(MarkdownRenderer):
func_prefix = Field(str, default=None)

module_overview = Field(str, default=None)
def __init__(self, func_prefix=None, module_overview=None, *args, **kwargs):
self.func_prefix = func_prefix
self.module_overview = module_overview

# Ensure that kwargs contain the necessary fields for MarkdownRenderer
super().__init__(*args, **kwargs)

# Overriding header levels from MarkdownRenderer to Function header to level 2
header_level_by_type = Field({int}, default={
Expand Down Expand Up @@ -158,9 +161,14 @@ def _process(self, node):

class IgnoreDocstringProcessor(FilterProcessor):
def process(self, modules, _resolver):
for module in modules:
print(f"Module: {module.name}")
for member in module.members:
if member.docstring:
print(f" - Member: {member.name}\n Docstring content: {member.docstring.content}\n")
filtered_modules = []
for member in getattr(modules[0], 'members', []):
if member.docstring and 'ignore docstring' not in member.docstring:
if member.docstring and member.docstring.content and 'ignore docstring' not in member.docstring.content:
filtered_modules.append(member)
else:
print(f'Skipping {member}')
Expand Down
35 changes: 34 additions & 1 deletion content-repo/gendocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import traceback
import tempfile
import yaml
import functools
Fixed Show fixed Hide fixed

from datetime import datetime
from distutils.version import StrictVersion
Expand All @@ -27,7 +28,10 @@
from CommonServerPython import tableToMarkdown # type: ignore
from mdx_utils import (fix_mdx, fix_relative_images, normalize_id,
start_mdx_server, stop_mdx_server, verify_mdx_server)

from demisto_sdk.commands.content_graph.interface.neo4j.neo4j_graph import (
Neo4jContentGraphInterface as ContentGraphInterface,
)
from neo4j import Transaction
# override print so we have a timestamp with each print
org_print = print

Expand Down Expand Up @@ -872,6 +876,33 @@ def generate_items(doc_infos, full_prefix):

return items_list

def query_content_items_marketplaces(tx: Transaction) -> list[dict]:
"""
Queries the content graph for content items and their associated marketplaces.
"""
result = tx.run(
"""
MATCH (n)
WHERE (n:Integration OR n:Script OR n:Playbook)
WITH n.object_id AS object_id, n.marketplaces AS marketplaces
WITH object_id, collect(marketplaces) AS marketplaces
RETURN apoc.map.fromPairs(collect([object_id, marketplaces])) AS resultJson
"""
).single()
return result["resultJson"] if result else {}


@functools.lru_cache
def get_all_content_items_ids_to_marketplaces() -> dict[str, list[str]]:
"""Return a dictionary where the key is the content item ID and the value is the marketplaces.

Returns:
dict[str, list[str]]: Mapping of content item IDs to their marketplaces.
"""
with ContentGraphInterface() as graph:
with graph.driver.session() as session:
return session.execute_read(query_content_items_marketplaces)


def main():
parser = argparse.ArgumentParser(description='''Generate Content Docs. You should probably not call this script directly.
Expand All @@ -881,6 +912,8 @@ def main():
parser.add_argument("-d", "--dir", type=os.path.normpath, help="Content repo dir.", required=True)
parser.add_argument("-b", "--branch", help="Content repo branch.", required=True)
args = parser.parse_args()
dict_item_to_marketplaces = get_all_content_items_ids_to_marketplaces()
print(f"{dict_item_to_marketplaces=}")
print(f'Using multiprocess pool size: {POOL_SIZE}')
print('Starting MDX server...')
start_mdx_server()
Expand Down
Loading
Loading