Python Sphinx Validate and update schema - python-sphinx

I'm using Sphinx to maintain docs on a project, I am generating a jsonschema document from a tool where all properties of objects are listed.
Those objects properties are documented in rst files, I need to:
I've managed to read the rst files in the doctree-resolved event, and match with the json property, but I'm not sure if this is the best approach since I need
a) check all properties are documented, this is almost donde, I can mark on the json properties found and then check the json at the end.
b) Copy the description retrieved from the doctree object in the json (adding a property to the json) the format I need is markup, so I need to figure out how to convert a doctree node(set) to markup. Also the url links should be working at this stage. Also if markdown is not possible converting the fragment to html then to markdown might be easier
I don't know if I'm in the right path or should I write a builder instead?
Thanks

Related

Gatsby & GraphQL: Transforming a String field into markdown

I have a GraphQL schema on a headless CMS. I'm using gatsby-source-graphql on a Gatsby site to get data from it.
There is a content field MyType_BlogPost.body of type String. This contains markdown code.
Is it possible to transform (with gatsby-transformer-remark) that into MarkdownRemark (or similar) so that it will automatically get subfields like html that contain the data one would expect (html code transformed from the markdown source)? I suspect subfields would be the way to do this, but I'm not 100 % of that.
I also suspect this could help but I'm not sure: https://www.gatsbyjs.org/docs/schema-customization/
Thank you.
If the field contains markdown code which you would like to transform into html, you should be able to do that using remark.
Remark is the library that gatsby-transformer-remark uses under the hood.
https://remark.js.org/
Specifically, look at the API section in their docs.

VuePress: How to modify the markdown content

VuePress (v1) provides this API to access the page context: https://v1.vuepress.vuejs.org/plugin/option-api.html#extendpagedata
I can access these properties but I can't change the value of _content for instance.
I would like to modify (replace some regexp) the markdown before it get's rendered by Vue (an even before it's get parsed by the markdown parser).
Maybe it makes more sense to do it with a markdown-it plugin using the chainmarkdown API but I don't know how exactly. But the question is more how to write a plugin for markdown-it which can modify the content before even parsing, because I need the raw text.
Here is one markdown-it plugin that allows you to do exactly that by defining regular expressions: https://www.npmjs.com/package/markdown-it-regexp

How to add metadata to the document using marklogic mapreduce connector api

I wanted to write the document to marklogic database using marklogic mapreduce api, lets say here is the example. I wanted to add metadata to the document which i am writing it back to the marklogic database in the reducer -
context.write(outputURI, result);
If adding metadata to the document with mapreduce api of marklogic is possible please let me know.
For Metadata, I am assuming you are talking about the document properties fragment. For background on document properties, please see here: https://docs.marklogic.com/guide/app-dev/properties#id_19516
For use in MarkLogic mapreduce, please see here (the output classes):
https://docs.marklogic.com/guide/mapreduce/output#id_76625
I believe you need to extend/modify your example to also write content to the properties fragment using the PropertyOutputFormat class.
One of the sample applications in the same documentation is an example of saving content in the properties fragment. If, however, you would like to fast-track yourself by looking at some source code: see some examples - including writing to a document property fragment, see here: https://gist.github.com/evanlenz/2484318 - specifically LinkCountInProperty.java
Used property mapreduce.marklogic.output.content.collection with the configuration xml. Adding this property added inserted data to that collection.

ApiBlueprints parameter that yield result like Stripe's errors "attributes"?

I'm new to Stripe and I'd like generate a result that looks like the "Attributes" part of the Errors part : https://stripe.com/docs/api/curl#errors
It's looks like a table with two column, even though it's not a table.
I don't know how I can make this.
For information, I'm using Aglio to generate the template.
Cyril,
There is no easy way to do this in Markdown that I know of. You have two options:
Create your own layout template that manually adds this information, then tell aglio to use it.
Include some basic HTML in your API Blueprint. Here is an example. It just creates a definition list which describes the error attributes using the same CSS that already exists on the page to describe URI parameters.
You can use Markdown to create the tables of response types and codes, and if you want to use a three-column layout you can use the middle and right CSS classes.
Hope this helps!

Parse excel document string without file path in ruby

Is there a way or a gem to parse an xlsx document string without having a file? I was using Roo to parse the excel file when it was on my local machine but I would like to do it without downloading the actual document. I receive it in my google mailbox, and can pull the excel document string but can't find any way to parse just the string without a file path. Any ideas would be appreciated.
You should be able to wrap your string in a StringIO object that will expose a similar API as File objects. Unfortunately, it looks like Roo has a lot of file handling built in to the various classes, and expects a pathname in the initialize method. As I see it you have a few options:
Subclass one of Roo's spreadsheet classes to override the file handling, and substitute in your StringIO object.
Save the string to a Tempfile and pass the temporary path into one of Roo's standard initializers (I suspect this would be easier to implement).
You can not parse a file without supplying it to your parser.
So at one point or another you will have to download the file, so that the parser has anything he can read for parsing.

Resources