Comments (9)
Former d3-style API proposal below.
API
# .site_name(language[,options]): {description}
language
: string.options
: object.
# .login(username, password, API_URL): login into the target API using the provided username and password.
username
: string - Account username. For bot, see [Special:BotPasswords] on your wiki.password
: string - Account's password. For bot, see [Special:BotPasswords] on your wiki.API_URL
: string (url) - Target wiki's API url.
# .query(parameters[,options]): {description}
parameters
:options
: object.
# .page(title[,options]): given a title, returns the page's data.
title
: string.options
: object.
# .tracking_revisions(title,to_search[,options]): {description}
title
: string.to_search
: …options
: object.
# .edit_page(title, function(d){…}[,options]): edits content of target page.
title
: string.conent
: string - Usefunction(d){…}
to return the new wikicode, whered
is the page data.options
: object.bot
: boolean.nocreate
: boolean - Avoid creating new page.minor
: boolean - Edit is minor.summary
: string - Edit summary.
# .edit(content[,options]) {…}: to use with and after edit_page
. {description}
content
: …options
: object.
# .move_to(move_to_title[,options]): move page to new title address.
move_to_title
: string.options
: object.reason
: string.noredirect
: booleanmovetalk
: boolean.
# .move_page(move_from_title, move_to_title[,options]): moves target page to new title address.
move_from_title
: string.move_to_title
: string.options
: object.reason
: string.noredirect
: booleanmovetalk
: boolean.
# .purge(title[,options]): {description}
title
: string.options
: object.
# .listen(listener[,options]listener, options) {}: to use with and after …. {description}
listener
: …options
: object.
# .category_tree(root_category[,options]): {description}
root_category
: string.options
: object.
# .search(key[,options]): {description}
key
: …options
: object.
# .redirects_root(title[,options]): {description}
title
: string.options
: object.
# .redirects_here(title[,options]): {description}
title
: string.options
: object.
# .register_redirects(template_name[,options]): {description}
template_name
: string.options
: object.
# .upload(file_data): given a target file, upload it to the target wiki.
file_data
: object - Upload configurations.file_path
: string - Local path. Alternative to media_url.media_url
: string - URL path. Alternative to file_path.comment
: string - Upload comment.text
: string - Wikicode which to fill the file's page. Alternative for most fields below.description
: string - File description.date
: date string - YYYY-MM-DD, ex: new Date() || '2021-01-01'.source_url
: string - Source where the file comes from, typically an url.author
: string - Author's name or username in wikicode, ex: '[[User:Yoda|Yoda]]'.permission
: string - …, ex: '{{cc-by-sa-2.5}}'.other_versions
: string - Wikicode displaying alternative files.other_fields
: string - …license
: array of strings - License under which the file is uploaded, ex: ['{{cc-by-sa-2.5}}'].categories
: array of strings - Categories for this file, ex: ['[[Category:test images]]'].ignorewarnings
: boolean=0 - Overwrite existing files.
# .get_featured_content(options): {description}
options
: object.
# .for_each_page(page_list, for_each[,options]): {description}
page_list
: …for_each
: …options
: object.
# .for_each(type, title, for_each[,options]): {description}
type
: …title
: string.for_each
: …options
: object.
# .data(key, property[,options]): {description}
key
: …property
: string.options
: object.
# .convert_Chinese(text[,options]): {description}
text
: string - … <------------------- wikicode ? raw text ?options
: object.
# .run_SQL(SQL, for_each_row): {description}
SQL
: …for_each_row
: …
# .setup_layout_elements(options): {description}
options
: object.
Helpers
Here we could list all options ?
Here comes page_data's explainer
Other tricks
Notes and Q&A
- Missing contents as
…
. - Missing
{description}
. Good practice isGiven {input} does {something}
orGiven {input} return {something} in {format}
. Format being string, object, array, number, etc. - Missing
get_featured_content
andsetup_layout_elements
. - Missing
categoryembers
:
# .categorymembers(title[,options]): returns an array of members.
title
: string. Category's name.
- Missing .data() sub-methods : .entity(), .modify().
Comment
Well....I didn't expected this but I did it most of it. I thing you can complete the blanks easily.
from wikiapi.
Maybe we can also use https://github.com/jsdoc/jsdoc ?
from wikiapi.
try https://kanasimi.github.io/wikiapi/
from wikiapi.
Substantial changes of documents have ended now.
from wikiapi.
I don't know yet how to create this man, as a readme, or by improving the in-code phrasing within wikiapi.js and test.js. But for reference, see best practice for README.md API with d3-array :
# d3.max(iterable[, accessor]) · Source.
Returns .... If ..., returns.... An optional option_name does ....
See also related_stuff.
I'am starting work below. Still a testing around, style and things can change. Please tell me if I'am on the right road. Help welcome. Kanasimi, I believe you have the userrights to edit my post, feel free to do so
from wikiapi.
TL;DR: expand readme above will be faster. Code clean up required. Then JSdoc3 can come over.
Long version : I'am discovering JSdoc3. On the long run it's a very good idea. But as of now I lack visibility.
Your wikiapi.js code currently has (i think) a mix of comment syntaxes. I have no idea how it will play out with installing JSdoc. Aside, JSdoc renderings that I checked are not concise.
Meanwhile, the markdown API draft above is 1~2h away from becoming a clean documentation for +90% of wikiapi.js code and methods. This will be concise and elegant.
Later on, this markdown can be converted back into JSdoc3, when ready. Namely :
- wikiapi.js comments cleaned up,
- you/we properly learnt JSdoc3 syntaxes,
- we know which template to use,
- we know which project to use (JSDoc GitHub Action, jsdoc-to-markdown, other ?)
Then, some regex will help convert :
<a name="move_to" href="#move_to">#</a> .<b>move_to</b>(<i>move_to_title</i>[,<i>options</i>]): move page to new title address.
* `move_to_title`: string - target page's title.
* `options`: object - options.
* `reason`: string - reason for the move.
* `noredirect`: boolean
* `movetalk`: boolean.
...into...
/**
* @alias .move_to
* @description Moves page to new title address.
* @param {String} move_to_title - target page's title.
* @param {Object} [options] - options.
* @param {String} [options.reason] - reason for the move.
* @param {Boolean=1} [options.noredirect] - do not leave a redirect.
* @param {Boolean=1} [options.movetalk] - move the talkpage as well.
* @returns {Object} - returns (does not exist on .move_to but I put it here for demo)
* @memberof Wikiapi.prototype
* @example
* result = await targetWiki.move_page('Page A', 'Page Alpha', { reason: 'Correcting name.', noredirect: true, movetalk: true });
*/
function move_to (move_to_title,options) {
// do stuff here
}
If you have the ability to make a quick, full JSdoc3 migration (points 1, 2, 3 and 4 above), go ahead.
But overall and given the main objective is to provide an API soon, I suggest to expand the markdown API drafted above. It will give you time to clean the wikiapi.js's comments and other improvements you see fit. Both actions prepare for a later JSdoc3 migration.
(Also since I have to catch upover my IRL todo list, I should better not be active this weekend and the coming week.)
from wikiapi.
Nice
from wikiapi.
Saw today changes. Starts to be awesome !
from wikiapi.
Good work done. Close. Thank @kanasimi !
from wikiapi.
Related Issues (20)
- Edit repository details to add `wikiapijs` tag. HOT 4
- Clarify naming convention (project branding) HOT 5
- Unexpected edit on bot's userpage HOT 3
- Upload upon : no edit of the page ? HOT 3
- Upload of missing file crashes script. HOT 6
- Download all files from a (Commons) category HOT 3
- Snowpack support HOT 9
- SyntaxError: Unexpected token '.' HOT 8
- Example broken on OSX HOT 5
- download is not a function HOT 4
- `.download()` scalability ? HOT 6
- "Too many values supplied for parameter \"pageids\". The limit is 50." HOT 3
- `.download()` : reduce calls to api.php, directly hit on https://upload.wikimedia.org HOT 9
- Cannot download : triggerUncaughtException HOT 6
- `.download()` : compare local and remote files by timestamps before downloading HOT 4
- `.download()`: `session.to_namespace('Category Name', 'Category')` needed HOT 1
- `.download()` on category, recursive : questions. HOT 4
- throws "API_URL.includes" is not a function when creating wikiapi instance HOT 5
- Please publish new version with delete
- Provide an option to set a custom User-Agent string HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wikiapi.