Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

documentary

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

documentary - npm Package Compare versions

Comparing version 1.34.10 to 1.34.11

38

build/components/index.js
const { h } = require('preact');
const { makeMethodTable } = require('./Typedef/lib');
const { relative, dirname } = require('path');
const $_shell = require('./shell');

@@ -9,2 +12,8 @@ const $_Argufy = require('./Argufy');

module.exports={
'type-link'({ documentary }) {
return documentary.removeLine()
},
}
/**

@@ -14,3 +23,3 @@ * @param {Object} params

*/
function method({ name, level, documentary, children, noArgTypesInToc }) {
function method({ name, level, documentary, children, noArgTypesInToc, 'just-heading': justHeading = false }) {
let [ns,type,m] = name.split('.')

@@ -37,3 +46,28 @@ if (!m) {

})
return res
const {
_args: { wiki, source }, currentFile,
} = documentary
const file = wiki ? source : currentFile
const linking = ({ link, type: refType }) => {
// when splitting wiki over multiple pages, allows
// to create links to the exact page.
const l = `#${link}`
// semi-hack
if (refType.appearsIn.includes(file)) return l
const ai = refType.appearsIn[0]
let rel = relative(dirname(file), ai)
if (wiki) rel = rel.replace(/\.(md|html)$/, '')
return `${rel}${l}`
}
if (justHeading) return res
let table = ''
try {
table = makeMethodTable(prop, documentary.allTypes, {
link: linking,
})
} catch (err) {
console.warn(err.message)
}
return [res, table].filter(Boolean).join('\n\n')
}

@@ -40,0 +74,0 @@ // export { default as method } from './method'

45

build/components/Typedef/index.js

@@ -9,2 +9,31 @@ const { h } = require('preact');

// const extractPages = (props) => {
// return Object.entries(props).reduce((acc, [key, val]) => {
// if (key.startsWith('page-')) {
// key = key.replace('page-', '')
// acc[key] = val
// }
// return acc
// }, {})
// }
const makeLinking = (wiki, file) => {
const linking = ({ link, type: refType }) => {
// when splitting wiki over multiple pages, allows
// to create links to the exact page.
const l = `#${link}`
// <type-link> component will set `typeLink`
if (refType.typeLink) return `${refType.typeLink}${l}`
// semi-hack
const { appearsIn = [''] } = refType
if (appearsIn.includes(file)) return l
const ai = appearsIn[0] //
let rel = relative(dirname(file), ai)
if (wiki) rel = rel.replace(/\.(md|html)$/, '')
return `${rel}${l}`
}
return linking
}
/**

@@ -37,13 +66,4 @@ * @param {Object} opts

const linking = ({ link, type: refType }) => {
// when splitting wiki over multiple pages, allows
// to create links to the exact page.
const l = `#${link}`
// semi-hack
if (refType.appearsIn.includes(file)) return l
const ai = refType.appearsIn[0]
let rel = relative(dirname(file), ai)
if (wiki) rel = rel.replace(/\.(md|html)$/, '')
return `${rel}${l}`
}
const linking = makeLinking(wiki, file)
const preprocessDesc = (d) => {

@@ -264,2 +284,3 @@ if (!d) return d

module.exports = Typedef
module.exports = Typedef
module.exports.makeLinking = makeLinking

@@ -22,5 +22,20 @@ const { c, b } = require('../../stdlib');

meta.setPretty(true, 100)
const documentary = getDocumentary()
documentary.renderAgain = meta.renderAgain
documentary.setPretty = meta.setPretty
const d = getDocumentary()
const documentary = new Proxy(d, {
get(target, p) {
if (p == 'renderAgain') {
return meta.renderAgain
}
if (p == 'setPretty') {
return meta.setPretty
}
if (p == 'removeLine') {
return () => {
meta.removeLine()
return null
}
}
return target[p]
},
})
return {

@@ -27,0 +42,0 @@ ...htmlProps,

/**
* Finds the `%TYPEDEF types.xml TypeName%` marker.
*/
const typedefMdRe = /^ *%TYPEDEF (.+?)(?: (.+?))?%$/mg
const typedefMdRe = /^ *%TYPEDEF (.+?)(?: (.+?))?%(-.+)?$/mg
module.exports.typedefMdRe = typedefMdRe

@@ -76,3 +76,3 @@ const { Replaceable, replace } = require('../../stdlib');

re: typedefMdRe,
async replacement(match, location, typeName) {
async replacement(match, location, typeName, link) {
const file = this.file // read early before async

@@ -92,2 +92,3 @@

file,
link,
})

@@ -104,3 +105,4 @@ } catch (e) {

this.locations = {}
this.on('types', ({ location, types, typeName, file }) => {
this.on('types', ({ location, types, typeName, file, link = '' }) => {
link = link.replace(/^-/, '')
if (wiki) {

@@ -128,3 +130,4 @@ const rf = relative(source, file)

}
b.appearsIn = [file]
if (!link) b.appearsIn = [file]
else b.typeLink = link // set arbitrary link to use for linking in typedef/index.jsx
if (imp) {

@@ -142,3 +145,5 @@ this.log('Adding import %s', fullName)

}
this.log('Adding type %s at %s', fullName, this.file)
if (link)
this.log('Adding type link %s to %s', fullName, link)
else this.log('Adding type %s at %s', fullName, this.file)
this.types.push(b)

@@ -148,2 +153,3 @@ return b

// this.types.push(...types)
if (link) return
const oldLocationTypes = this.locations[location] || []

@@ -213,2 +219,8 @@ this.locations = {

},
'type-link'({ link, children }) {
let [loc] = children
loc = loc.trim()
const r = `%TYPEDEF ${loc}%-${link}`
return r
},
})

@@ -215,0 +227,0 @@

## 19 December 2019
### [1.34.11](https://github.com/artdecocode/documentary/compare/v1.34.10...v1.34.11)
- [feature] Type linking across pages.
### [1.34.10](https://github.com/artdecocode/documentary/compare/v1.34.9...v1.34.10)

@@ -4,0 +8,0 @@

{
"name": "documentary",
"version": "1.34.10",
"version": "1.34.11",
"description": "Documentation Compiler To Generate The Table Of Contents, Embed Examples With Their Output, Make Markdown Tables, Maintain Typedefs For JavaScript And README, Watch Changes To Push, Use Macros And Prettify API Titles.",

@@ -121,4 +121,4 @@ "main": "build",

"preact": "8.5.3",
"typal": "^1.24.14"
"typal": "^1.24.15"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc